Skip to content

Potentially mis-specified selection in emcncf() #209

@jonasfreimuth

Description

@jonasfreimuth

Hello everyone,

first of all, thanks for providing this handy package!

When troubleshooting my own issues with purity being reported as NA, I noticed that when checking for a pure and diploid tumor (

if(all(seg$tcn[seg$chrom<nX]==2 & seg$lcn[seg$chrom<nX]%in%c(1, NA))|max(mafR.clust[seg$chrom<nX & seg$nhet>min.nhet], na.rm = TRUE) < 0.05){
), the check whether any of the cluster mafR is below the threshold of 0.05 has a misspecified selection vector. The mafR.clus object is a vector of length(unique(seg$segclust)), but the selection vector has nrow(seg) elements. In the worst case, this could lead to a sample being reported as diploid and no tumor purity being reported when that is not acutally the case, but seg$chrom < nX & seg$nhet > min.nhet happened to be FALSE for all elements where the mafR.clust vector was not NA (i.e., when all the segments, whose id/position corresponded to a segclust ID/position with a non-NA mafR.clust value, happend to be below the nhet threshold). I don't know how likely this is, but it can't be ruled out that some of the open issues reporting Warning message: In max(mat$chrom) : no non-missing arguments to max; returning -Inf (which is the result of max not getting any non-NA input), namely #39, #46, and #86, may have encountered this issue when it can't be ruled out that it's strictly due to not enough segments passing the nhet threshold.

In any case, subsetting by a vector that is almost always too long is something that is hard to spot when reading the code, so as far as I can tell this should be fixed. I'd propose just replacing it with seg$mafR.clust[seg$chrom < nX & seg$nhet > min.nhet], and getting rid of the the mafR.clust object entirely, since AFAICT, the mafR.clust column in the seg dataframe is already uniform for each cluster.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions