Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 59 #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions R/msqrob-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -151,7 +151,7 @@ setMethod(
lmerArgs = lmerArgs
)
}

rowData(object)[[modelColumnName]] <- rowData(object)[[modelColumnName]][rownames(rowData(object))]
return(object)
}
Expand Down Expand Up @@ -186,42 +186,42 @@ 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
)
} else {
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,
Expand All @@ -231,7 +231,7 @@ setMethod(
lmerArgs = lmerArgs
)
}

rowData(object[[i]])[[modelColumnName]] <- rowData(object[[i]])[[modelColumnName]][rownames(rowData(object[[i]]))]
return(object)
}
Expand Down
Loading