Added lines to update names of columns so that plots and models use columns provided as parameters to functions - #13
Open
JTumulty wants to merge 6 commits into
Open
Added lines to update names of columns so that plots and models use columns provided as parameters to functions#13JTumulty wants to merge 6 commits into
JTumulty wants to merge 6 commits into
Conversation
Rename columns before plotting
Rename provided columns before plotting
Rename provided columns before plotting
Rename provided columns before fitting model
Rename provided column
Add parameters "detected=" and "subsets_mito_percent=" to function and rename columns in data frame based on provided value. Also updated list of parameters to include these
There was a problem hiding this comment.
Pull request overview
This PR aims to make miQC plotting/modeling/filtering functions honor user-specified detected= and subsets_mito_percent= column names (instead of implicitly requiring canonical colData column names), addressing issue #12.
Changes:
- Added logic in plotting/modeling/filtering helpers to map user-provided metric column names onto the expected canonical names.
- Extended
filterCells()to acceptdetectedandsubsets_mito_percentparameters and documented them. - Updated
mixtureModel()andget1DCutoff()to remap metric columns before fitting/cutoff computation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| R/plotMetrics.R | Renames/aliases metric columns prior to ggplot usage. |
| R/plotFiltering.R | Renames/aliases metric columns prior to plotting and optional model creation. |
| R/plotModel.R | Renames/aliases metric columns prior to plotting and optional model creation. |
| R/mixtureModel.R | Renames/aliases metric columns prior to flexmix() fitting. |
| R/get1DCutoff.R | Renames/aliases mito-percent column prior to cutoff computation and optional model creation. |
| R/filterCells.R | Adds detected/subsets_mito_percent params and renames/aliases columns prior to filtering and optional model creation. |
Comments suppressed due to low confidence (5)
R/plotFiltering.R:74
plotFiltering()acceptsdetected/subsets_mito_percent, but whenmodelis NULL it callsmixtureModel(sce)without forwarding those parameters. If the user provides custom column names (or the canonical columns are absent), this will still build a model against the defaults and can error or fit on the wrong data. Passdetected=detectedandsubsets_mito_percent=subsets_mito_percentinto themixtureModel()call here.
if (is.null(model)) {
warning("call 'mixtureModel' explicitly to get stable model features")
model <- mixtureModel(sce)
}
R/plotModel.R:52
plotModel()acceptsdetected/subsets_mito_percent, but whenmodelis NULL it callsmixtureModel(sce)without forwarding those parameters. This breaks the intended support for custom column names (the model will still be fit using default column names). Forwarddetectedandsubsets_mito_percenttomixtureModel()here.
if (is.null(model)) {
warning("call 'mixtureModel' explicitly to get stable model features")
model <- mixtureModel(sce)
}
R/mixtureModel.R:55
- The column-renaming logic has the same duplicate-name risk as in the plotting functions: if
metricsalready has adetected/subsets_mito_percentcolumn and the user pointsdetected/subsets_mito_percentat a different column, you can end up with duplicate canonical names andflexmix()may fit on the wrong one. Consider settingmetrics$detected/metrics$subsets_mito_percentfrom the user-specified columns (overwriting if needed) and validating the requested columns exist before fitting.
metrics <- as.data.frame(colData(sce))
colnames(metrics)[colnames(metrics)==detected] <- "detected"
colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent"
if (model_type == "linear") {
model <- flexmix(subsets_mito_percent~detected,
data = metrics, k = 2)
R/get1DCutoff.R:52
get1DCutoff()acceptssubsets_mito_percent, but whenmodelis NULL it callsmixtureModel(sce, model_type = "one_dimensional")without forwardingsubsets_mito_percent. This will still expect asubsets_mito_percentcolumn insceand defeats the purpose of the parameter. Forwardsubsets_mito_percent=subsets_mito_percentinto themixtureModel()call.
if (is.null(model)) {
warning("call 'mixtureModel' explicitly to get stable model features")
model <- mixtureModel(sce, model_type = "one_dimensional")
}
R/filterCells.R:75
filterCells()now acceptsdetected/subsets_mito_percent, but whenmodelis NULL it callsmixtureModel(sce)without forwarding those parameters. This means custom column names still won't work unless the caller manually precomputesmodel. Passdetected=detectedandsubsets_mito_percent=subsets_mito_percentinto themixtureModel()call here.
if (is.null(model)) {
warning("call 'mixtureModel' explicitly to get stable model features")
model <- mixtureModel(sce)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+46
to
+47
| colnames(metrics)[colnames(metrics)==detected] <- "detected" | ||
| colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" |
Comment on lines
+68
to
+69
| colnames(metrics)[colnames(metrics)==detected] <- "detected" | ||
| colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" |
Comment on lines
+46
to
+47
| colnames(metrics)[colnames(metrics)==detected] <- "detected" | ||
| colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" |
Comment on lines
+69
to
+70
| colnames(metrics)[colnames(metrics)==detected] <- "detected" | ||
| colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" |
| get1DCutoff <- function(sce, model = NULL, posterior_cutoff = 0.75, | ||
| subsets_mito_percent = "subsets_mito_percent") { | ||
| metrics <- as.data.frame(colData(sce)) | ||
| colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added lines to update names of data frame columns in plotMetrics.R, plotModel.R, plotFiltering.R, mixtureModel.R, get1DCutoff.R, and filterCells.R, so that data from columns provided to parameters "detected" and "subset_mito_percent" are used in plotting, model,s and filtering.
Related to issue #12