From b4917188b36704d5d9f37593523cad7923b26267 Mon Sep 17 00:00:00 2001 From: Thomas OBADIA <tobadia@pasteur.fr> Date: Fri, 29 Apr 2022 16:28:03 +0200 Subject: [PATCH] Sanitize a possible error in subsetting colums for L (that shouldn't have any consequences anyway) and harmonize grammar for mutate(across()) statements --- FUNCTIONS.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FUNCTIONS.R b/FUNCTIONS.R index aeb5cd6..e3bdc23 100644 --- a/FUNCTIONS.R +++ b/FUNCTIONS.R @@ -103,7 +103,7 @@ runRelativeAntibodyUnits = function(fname1, fname2, MFI_CSV, MFI_N_ANTIGENS, TEM dim(L) # MFI values as numeric - L[,-which(colnames(L) %in% c("Location","Sample","Total Events","TotalEvents"))] = lapply(L[,-which(colnames(L) %in% c("Location","Sample","Total Events"))], as.numeric) + L[,-which(colnames(L) %in% c("Location","Sample","Total Events","TotalEvents"))] = lapply(L[,-which(colnames(L) %in% c("Location","Sample","Total Events","TotalEvents"))], as.numeric) ## Load the counts to check for run quality control C = L_full[(count_row_number+1):(count_row_number+1+nrow(L)),1:(3+as.integer(MFI_N_ANTIGENS))] @@ -177,7 +177,7 @@ runRelativeAntibodyUnits = function(fname1, fname2, MFI_CSV, MFI_N_ANTIGENS, TEM L <- L %>% mutate_all(funs(gsub("NaN", 0, .))) # MFI values as numeric - L[,-which(colnames(L) %in% c("Location","Sample","Total Events","TotalEvents"))] = lapply(L[,-which(colnames(L) %in% c("Location","Sample","Total Events"))], as.numeric) + L[,-which(colnames(L) %in% c("Location","Sample","Total Events","TotalEvents"))] = lapply(L[,-which(colnames(L) %in% c("Location","Sample","Total Events","TotalEvents"))], as.numeric) C <- as.data.frame(read_excel(fname1, skip = count_row_number+1, col_types = "text")) @@ -247,7 +247,7 @@ runRelativeAntibodyUnits = function(fname1, fname2, MFI_CSV, MFI_N_ANTIGENS, TEM C <- L %>% dplyr::mutate(dplyr::across(!c(Location, Sample), gsub, pattern = "^(\\d+(?:\\.\\d+)?)(\\s*\\((\\d+(?:\\.\\d+)?)\\))?$", replacement = "\\3")) %>% # Set to NA in case bead counts were not available - dplyr::mutate(dplyr::across(!Location & !Sample, gsub, pattern = "^$", replacement = NA)) + dplyr::mutate(dplyr::across(!c(Location, Sample), gsub, pattern = "^$", replacement = NA)) dim(C) -- GitLab