Skip to content

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
greenelab:mainfrom
JTumulty:main
Open

Added lines to update names of columns so that plots and models use columns provided as parameters to functions#13
JTumulty wants to merge 6 commits into
greenelab:mainfrom
JTumulty:main

Conversation

@JTumulty

Copy link
Copy Markdown

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

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 accept detected and subsets_mito_percent parameters and documented them.
  • Updated mixtureModel() and get1DCutoff() 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() accepts detected/subsets_mito_percent, but when model is NULL it calls mixtureModel(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. Pass detected=detected and subsets_mito_percent=subsets_mito_percent into the mixtureModel() call here.
    if (is.null(model)) {
        warning("call 'mixtureModel' explicitly to get stable model features")
        model <- mixtureModel(sce)
    }

R/plotModel.R:52

  • plotModel() accepts detected/subsets_mito_percent, but when model is NULL it calls mixtureModel(sce) without forwarding those parameters. This breaks the intended support for custom column names (the model will still be fit using default column names). Forward detected and subsets_mito_percent to mixtureModel() 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 metrics already has a detected/subsets_mito_percent column and the user points detected/subsets_mito_percent at a different column, you can end up with duplicate canonical names and flexmix() may fit on the wrong one. Consider setting metrics$detected/metrics$subsets_mito_percent from 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() accepts subsets_mito_percent, but when model is NULL it calls mixtureModel(sce, model_type = "one_dimensional") without forwarding subsets_mito_percent. This will still expect a subsets_mito_percent column in sce and defeats the purpose of the parameter. Forward subsets_mito_percent=subsets_mito_percent into the mixtureModel() 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 accepts detected/subsets_mito_percent, but when model is NULL it calls mixtureModel(sce) without forwarding those parameters. This means custom column names still won't work unless the caller manually precomputes model. Pass detected=detected and subsets_mito_percent=subsets_mito_percent into the mixtureModel() 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 thread R/plotMetrics.R
Comment on lines +46 to +47
colnames(metrics)[colnames(metrics)==detected] <- "detected"
colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent"
Comment thread R/plotFiltering.R
Comment on lines +68 to +69
colnames(metrics)[colnames(metrics)==detected] <- "detected"
colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent"
Comment thread R/plotModel.R
Comment on lines +46 to +47
colnames(metrics)[colnames(metrics)==detected] <- "detected"
colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent"
Comment thread R/filterCells.R
Comment on lines +69 to +70
colnames(metrics)[colnames(metrics)==detected] <- "detected"
colnames(metrics)[colnames(metrics)==subsets_mito_percent] <- "subsets_mito_percent"
Comment thread R/get1DCutoff.R
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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants