Skip to content

Commit

Permalink
removed global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ec363 committed Nov 1, 2024
1 parent 540d21e commit b49e370
Show file tree
Hide file tree
Showing 13 changed files with 365 additions and 362 deletions.
12 changes: 6 additions & 6 deletions R/calc_fpconc.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ calc_fpconc <- function(data_csv,
# Calc
if(isFALSE(timecourse)){
percell_data <- percell_data %>%
dplyr::mutate(v1 = (.data[[flumeasure]]) / total_cell_volume_L )
dplyr::mutate(v1 = (.data[[flumeasure]]) / .data$total_cell_volume_L )
# divides norm GFP by cell volume
as.data.frame(percell_data)[1,]
} else if(isTRUE(timecourse)){
percell_data <- percell_data %>%
dplyr::group_by(.data$time) %>%
dplyr::mutate(v1 = (.data[[flumeasure]]) / total_cell_volume_L )
dplyr::mutate(v1 = (.data[[flumeasure]]) / .data$total_cell_volume_L )
# for each timepoint, divides norm GFP by cell volume
as.data.frame(percell_data)[1,]
}
Expand All @@ -188,7 +188,7 @@ calc_fpconc <- function(data_csv,
max_value <- max(percell_data[[paste0("normalised_", flu_labels[flu_idx], "_percellvolume")]], na.rm = TRUE)
plt_flu <-
ggplot2::ggplot(data = percell_data,
ggplot2::aes(x = column, y = row, fill = .data[[paste0("normalised_", flu_labels[flu_idx], "_percellvolume")]])) +
ggplot2::aes(x = .data$column, y = row, fill = .data[[paste0("normalised_", flu_labels[flu_idx], "_percellvolume")]])) +

ggplot2::geom_tile() +
ggplot2::scale_x_discrete("", position = "top",
Expand Down Expand Up @@ -291,13 +291,13 @@ calc_fpconc <- function(data_csv,
# #molar: 1M = 1mol/L
if(isFALSE(timecourse)){
percell_data <- percell_data %>%
dplyr::mutate(v1 = (.data[[moles_columnname]]) / total_cell_volume_L )
dplyr::mutate(v1 = (.data[[moles_columnname]]) / .data$total_cell_volume_L )
# divides calib GFP by cell volume
as.data.frame(percell_data)[1,]
} else if(isTRUE(timecourse)){
percell_data <- percell_data %>%
dplyr::group_by(.data$time) %>%
dplyr::mutate(v1 = (.data[[moles_columnname]]) / total_cell_volume_L )
dplyr::mutate(v1 = (.data[[moles_columnname]]) / .data$total_cell_volume_L )
# for each timepoint, divides calib GFP by cell volume
as.data.frame(percell_data)[1,]
}
Expand All @@ -318,7 +318,7 @@ calc_fpconc <- function(data_csv,
max_value <- max(percell_data[[paste0("calibrated_", flu_labels[flu_idx], "_Molar")]]*1e6, na.rm = TRUE)
plt_flu_calib <-
ggplot2::ggplot(data = percell_data,
ggplot2::aes(x = column, y = row, fill = .data[[paste0("calibrated_", flu_labels[flu_idx], "_Molar")]]*1e6)) +
ggplot2::aes(x = .data$column, y = row, fill = .data[[paste0("calibrated_", flu_labels[flu_idx], "_Molar")]]*1e6)) +

ggplot2::geom_tile() +
ggplot2::scale_x_discrete("", position = "top",
Expand Down
10 changes: 5 additions & 5 deletions R/calc_fppercell.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ calc_fppercell <- function(data_csv,
# heatmap1 - raw fluor
max_value <- max(percell_data[[flu_channels[flu_idx]]], na.rm = TRUE)
plt_flu <- ggplot2::ggplot(data = percell_data,
ggplot2::aes(x = column, y = row, fill = .data[[flu_channels[flu_idx]]])) +
ggplot2::aes(x = .data$column, y = row, fill = .data[[flu_channels[flu_idx]]])) +

ggplot2::geom_tile() +
ggplot2::scale_x_discrete("", position = "top",
Expand Down Expand Up @@ -199,7 +199,7 @@ calc_fppercell <- function(data_csv,
# heatmap2 - normalised fluor
max_value <- max(percell_data[[paste0("normalised_", flu_channels[flu_idx])]], na.rm = TRUE)
plt_flu <- ggplot2::ggplot(data = percell_data,
ggplot2::aes(x = column, y = row, fill = .data[[paste0("normalised_", flu_channels[flu_idx])]])) +
ggplot2::aes(x = .data$column, y = row, fill = .data[[paste0("normalised_", flu_channels[flu_idx])]])) +

ggplot2::geom_tile() +
ggplot2::scale_x_discrete("", position = "top",
Expand Down Expand Up @@ -273,7 +273,7 @@ calc_fppercell <- function(data_csv,
# heatmap - normalised fluor per OD
max_value <- max(percell_data[[paste0("normalised", flu_channels[flu_idx], "_perOD")]], na.rm = TRUE)
plt_flu <- ggplot2::ggplot(data = percell_data,
ggplot2::aes(x = column, y = row, fill = .data[[paste0("normalised", flu_channels[flu_idx], "_perOD")]])) +
ggplot2::aes(x = .data$column, y = row, fill = .data[[paste0("normalised", flu_channels[flu_idx], "_perOD")]])) +

ggplot2::geom_tile() +
ggplot2::scale_x_discrete("", position = "top",
Expand Down Expand Up @@ -465,7 +465,7 @@ calc_fppercell <- function(data_csv,
# heatmap - calibrated fluor
max_value <- max(percell_data[[paste0("calibrated_", flu_labels[flu_idx])]], na.rm = TRUE)
plt_flu_calib <- ggplot2::ggplot(data = percell_data,
ggplot2::aes(x = column, y = row, fill = .data[[paste0("calibrated_", flu_labels[flu_idx])]])) +
ggplot2::aes(x = .data$column, y = row, fill = .data[[paste0("calibrated_", flu_labels[flu_idx])]])) +

ggplot2::geom_tile() +
ggplot2::scale_x_discrete("", position = "top",
Expand Down Expand Up @@ -533,7 +533,7 @@ calc_fppercell <- function(data_csv,
# heatmap - calibrated fluor per cell
max_value <- max(percell_data[[paste0("calibrated", flu_labels[flu_idx], "_perCell")]], na.rm = TRUE)
plt_flu_calib <- ggplot2::ggplot(data = percell_data,
ggplot2::aes(x = column, y = row, fill = .data[[paste0("calibrated", flu_labels[flu_idx], "_perCell")]])) +
ggplot2::aes(x = .data$column, y = row, fill = .data[[paste0("calibrated", flu_labels[flu_idx], "_perCell")]])) +

ggplot2::geom_tile() +
ggplot2::scale_x_discrete("", position = "top",
Expand Down
8 changes: 6 additions & 2 deletions R/correct_flu.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ correct_flu <- function(pr_data,

pr_data <- pr_data %>%
# dplyr::mutate(flu_quench = param1*(normalised_OD_cm1)^2 + param2*(normalised_OD_cm1) + param3) %>% # handwritten version
dplyr::mutate(flu_quench = stats::predict(quench_model, .)) %>%
dplyr::mutate(v1 = .data[[paste0("normalised_", flu_channel)]] / flu_quench)

# dplyr::mutate(flu_quench = stats::predict(quench_model, .)) %>% # . here causes R CMD CHECK to flag a globalVariable NOTE
# dplyr::mutate(flu_quench = stats::predict(quench_model, .data)) %>% # .data here removes NOTE but makes fn fail
dplyr::mutate(flu_quench = stats::predict(quench_model, pr_data)) %>% # pr_data removes NOTE without error

dplyr::mutate(v1 = .data[[paste0("normalised_", flu_channel)]] / .data$flu_quench)
# flu_quench represents expected quenching that has already happened. so to correct for it we must divide by this
# eg if quench = 0.90, that suggests we are seeing 90% of the real value. dividing by 0.9 would help us correct this.
pr_data[1:5,]
Expand Down
Loading

0 comments on commit b49e370

Please sign in to comment.