Uses generatePCs() under the hood.
If HVGs are empty, selects HVGs via FindVariableFeatures(object, nfeatures)
with default nfeatures = 2000. If HVGs are present, the PCA uses
NFEATURES = length(HVGs(object)). This aligns the PCA feature count with
the
HVG selection while allowing an explicit override of nfeatures when empty.
Examples
data(Snail1KO)
counts <- as.matrix(Snail1KO$rawCounts)
counts <- counts[rowSums(counts >= 10) >= 3, ]
meta <- Snail1KO$metadata
rownames(meta) <- meta$Sample
norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1)
obj <- GenEDA(normalized = norm, metadata = meta, counts = counts)
obj <- RunPCA(obj, nfeatures = 1000)
#> HVG slot is empty. Running FindVariableFeatures with top 1000 genes
#> Calculating principal components from top 1000 HVGs
#> Percent variations:
#> PC1: 88.56 %
#> PC2: 5.9 %
#> PC3: 2.91 %
#> PC4: 1.55 %
#> PC5: 1.08 %
#> PC6: 0 %
DimReduction(obj)$percent_var
#> PC1 PC2 PC3 PC4 PC5 PC6
#> "88.56 %" "5.9 %" "2.91 %" "1.55 %" "1.08 %" "0 %"
