Skip to content

subsetting drops attributes from reducedDim(., "PCA") #86

@HelenaLC

Description

@HelenaLC

See title ... came across this working on some PCA-related things:

library(scater)
sce <- mockSCE()
sce <- logNormCounts(sce)
sce <- runPCA(sce)

pca <- reducedDim(sce, "PCA")
rot <- attr(pca, "rotation")
class(rot) # matrix

sub <- sce[, -1]
pcb <- reducedDim(sub, "PCA")
rot <- attr(pcb, "rotation")
class(rot) # NULL

Now, I'm aware this is not a SCE-specific thing, i.e., plain matrix subsetting does the trick:

names(attributes(pca))
# "dim" "dimnames" "varExplained" "percentVar" "rotation"
names(attributes(pca[1, ]))
# "dim" "dimnames"

However, I still wonder whether our "core" class for handling such data could somehow retain this information better? E.g., with rotations gone, it's impossible for me to tell what features underly the PCs in the object, etc.

Any thoughts, suggestions, further discussion appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions