welch-lab / liger

R package for integrating and analyzing multiple single-cell datasets
GNU General Public License v3.0
380 stars 78 forks source link

getProportionMito() is currently mouse-specific #271

Closed jowkar closed 10 months ago

jowkar commented 1 year ago

The function getProportionMito() is currently written such that it expects mouse gene symbols (i.e., lower case). See the second line in the body of the function code below. Could be fixed by making the grep pattern a parameter perhaps, with either "^mt-" or "^MT-" as default.

function (object, use.norm = FALSE) 
{
    all.genes <- Reduce(union, lapply(object@raw.data, rownames))
    mito.genes <- grep(pattern = "^mt-", x = all.genes, value = TRUE)
    data.use <- object@raw.data
    if (use.norm) {
        data.use <- object@norm.data
    }
    percent_mito <- unlist(lapply(unname(data.use), function(x) {
        colSums(x[mito.genes, ])/colSums(x)
    }), use.names = TRUE)
    return(percent_mito)
}

Suggestion:

function (object, use.norm = FALSE, mito_pattern = "^mt-") 
{
    all.genes <- Reduce(union, lapply(object@raw.data, rownames))
    mito.genes <- grep(pattern = mito_pattern, x = all.genes, value = TRUE)
    data.use <- object@raw.data
    if (use.norm) {
        data.use <- object@norm.data
    }
    percent_mito <- unlist(lapply(unname(data.use), function(x) {
        colSums(x[mito.genes, ])/colSums(x)
    }), use.names = TRUE)
    return(percent_mito)
}
cgao90 commented 1 year ago

Hi @jowkar,

This is a great suggestion! Really appreciate it. We will look into this and make a modification.

Best,