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

miQC: fix "undefined columns selected" if column renamed #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kew24
Copy link

@kew24 kew24 commented Aug 1, 2024

Users can choose their own percent.mt column name to fetch from their data, and the resulting column is subsequently renamed in as "percent.mt" in my_data:

seurat-wrappers/R/miqc.R

Lines 57 to 58 in 8d46d6c

my_data <- Seurat::FetchData(object, vars = c(percent.mt, nFeature_RNA))
colnames(my_data) <- c("percent.mt", "nFeature_RNA")

However, when subsetting on lines 120 & 126 (if the else if conditions of lines 117-127 are met), we get "undefined columns selected" errors if the user passed in anything other than the default to percent.mt – because we're subsetting using the value stored in the percent.mt variable:

seurat-wrappers/R/miqc.R

Lines 117 to 127 in 8d46d6c

else if (backup.option == "percentile") {
message("defaulting to backup.percentile for filtering")
compromised_probability <- 0
raw_values <- my_data[,percent.mt]
percentile_cutoff <- quantile(raw_values, probs = backup.percentile)
cells_to_keep <- ifelse(raw_values <= percentile_cutoff, "keep", "discard")}
else if (backup.option == "percent"){
message("defaulting to backup.percent for filtering")
compromised_probability <- 0
raw_values <- my_data[,percent.mt]
cells_to_keep <- ifelse(raw_values <= backup.percent, "keep", "discard")}

Solutions include either reassigning percent.mt <- "percent.mt" after line 58, or subsetting on line 120 & 126 with the character value "percent.mt" that we've forced the column to be named as. I chose the latter of these two options.

Let me know if you have any comments, and feel free to edit if necessary. Thanks!

@kew24 kew24 changed the title fix "undefined columns selected" if column renamed miQC: fix "undefined columns selected" if column renamed Aug 1, 2024
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.

1 participant