From e47b2d2e49cd0fe7b4c0ef7597d534574db9475b Mon Sep 17 00:00:00 2001 From: StijnVandenbulcke Date: Tue, 7 May 2024 16:52:08 +0200 Subject: [PATCH 1/2] Fixed incorrect subsetting related to the coldata --- R/msqrob-methods.R | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/R/msqrob-methods.R b/R/msqrob-methods.R index 77a6758..f8c9101 100644 --- a/R/msqrob-methods.R +++ b/R/msqrob-methods.R @@ -103,32 +103,32 @@ setMethod( "\' in the rowData of the SummarizedExperiment object, set the argument overwrite=TRUE to replace the column with the new results or use another name for the argument modelColumnName to store the results as a novel column in the rowData of SummarizedExperiment object" ) } - + if (length(formula) == 3) { formula <- formula[-2] } - + if (any(all.vars(formula) %in% colnames(rowData(object)))){ stop( "Use the msqrobAggregate function to use rowData variables" ) } - - - - #Get the variables from the formula and check if they are in the coldata or rowdata + + + + #Get the variables from the formula and check if they are in the coldata or rowdata check_vars <- all.vars(formula) %in% colnames(colData(object)) if (!all(check_vars)){ if(sum(!check_vars) >1) { vars_not_found <- paste0(all.vars(formula)[!check_vars], collapse=", ") - stop(paste("Variables", vars_not_found, "are not found in coldata"), sep = "") + stop(paste("Variables", vars_not_found, "are not found in coldata"), sep = "") } else{ vars_not_found <- all.vars(formula)[!check_vars] - stop(paste0("Variable ", vars_not_found, " is not found in coldata"), sep = "") + stop(paste0("Variable ", vars_not_found, " is not found in coldata"), sep = "") } } - - + + if (!ridge & is.null(findbars(formula))) { rowData(object)[[modelColumnName]] <- msqrobLm( y = assay(object), @@ -151,7 +151,7 @@ setMethod( lmerArgs = lmerArgs ) } - + rowData(object)[[modelColumnName]] <- rowData(object)[[modelColumnName]][rownames(rowData(object))] return(object) } @@ -186,34 +186,34 @@ setMethod( "of the QFeatures object, set the argument overwrite=TRUE to replace the column with the new results or use another name for the argument modelColumnName to store the results as a novel column in the rowData of assay of the QFeatures object" ) } - + if (length(formula) == 3) { formula <- formula[-2] } - + if (any(all.vars(formula) %in% colnames(rowData(object[[i]])))){ stop( "Use the msqrobAggregate function to use rowData variables" ) } - - #Get the variables from the formula and check if they are in the coldata or rowdata + + #Get the variables from the formula and check if they are in the coldata or rowdata check_vars <- all.vars(formula) %in% colnames(colData(object)) if (!all(check_vars)){ if(sum(!check_vars) >1) { vars_not_found <- paste0(all.vars(formula)[!check_vars], collapse=", ") - stop(paste("Variables", vars_not_found, "are not found in coldata"), sep = "") + stop(paste("Variables", vars_not_found, "are not found in coldata"), sep = "") } else{ vars_not_found <- all.vars(formula)[!check_vars] - stop(paste0("Variable ", vars_not_found, " is not found in coldata"), sep = "") + stop(paste0("Variable ", vars_not_found, " is not found in coldata"), sep = "") } } - + if (!ridge & is.null(findbars(formula))) { rowData(object[[i]])[[modelColumnName]] <- msqrobLm( y = assay(object[[i]]), formula = formula, - data = droplevels(colData(object)), + data = droplevels(colData(getWithColData(object, i = i))) robust = robust, maxitRob = maxitRob ) @@ -221,7 +221,7 @@ setMethod( rowData(object[[i]])[[modelColumnName]] <- msqrobLmer( y = assay(object[[i]]), formula = formula, - data = droplevels(colData(object)), + data = droplevels(colData(getWithColData(object, i = i))), rowdata = NULL, robust = robust, ridge = ridge, @@ -231,7 +231,7 @@ setMethod( lmerArgs = lmerArgs ) } - + rowData(object[[i]])[[modelColumnName]] <- rowData(object[[i]])[[modelColumnName]][rownames(rowData(object[[i]]))] return(object) } From ae55b186a5878e60a871ae55895c44ebe03bd2ac Mon Sep 17 00:00:00 2001 From: StijnVandenbulcke Date: Tue, 7 May 2024 16:54:41 +0200 Subject: [PATCH 2/2] Forgot a comma --- R/msqrob-methods.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/msqrob-methods.R b/R/msqrob-methods.R index f8c9101..b422001 100644 --- a/R/msqrob-methods.R +++ b/R/msqrob-methods.R @@ -213,7 +213,7 @@ setMethod( rowData(object[[i]])[[modelColumnName]] <- msqrobLm( y = assay(object[[i]]), formula = formula, - data = droplevels(colData(getWithColData(object, i = i))) + data = droplevels(colData(getWithColData(object, i = i))), robust = robust, maxitRob = maxitRob )