Skip to contents

Looks for DEGs after filtering that overlap with HVGs.

Usage

FindHVDEGs(object, assay, direction = c("positive", "negative", "both"))

Arguments

object

A geneda object with a DEG table set via SetDEGs()

assay

The DEG slot to pull results from (typically a result of FilterDEGs)

direction

One of positive, negative, or both (indicating the direction of DEG fold change to intersect with HVGs)

Value

For direction = "positive" or "negative", a character vector of gene IDs that are both DEGs in that direction and HVGs. For direction = "both", a list with elements positive, negative, and both (all overlapping genes).

Examples

data(Snail1KO)
counts <- as.matrix(Snail1KO$rawCounts)
counts <- counts[rowSums(counts >= 10) >= 3, ]
meta <- Snail1KO$metadata
rownames(meta) <- meta$Sample
meta$Genotype <- factor(meta$Genotype, levels = c("WT", "Snai1_KO"))
norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1)
obj <- GenEDA(normalized = norm, metadata = meta, counts = counts)

# Differential expression with DESeq2 (Snai1_KO vs WT)
dds <- DESeq2::DESeqDataSetFromMatrix(counts, meta, design = ~Genotype)
dds <- DESeq2::DESeq(dds, quiet = TRUE)
res <- as.data.frame(DESeq2::results(dds))
obj <- SetDEGs(obj, res, assay = "KO_vs_WT")
obj <- FilterDEGs(obj, assay = "KO_vs_WT", saveAssay = "KO_vs_WT_filtered")
obj <- FindVariableFeatures(obj, nfeatures = 1000)
hv <- FindHVDEGs(obj, assay = "KO_vs_WT_filtered", direction = "both")
#> 475 +log2FC hvDEGs found.
#> 408 -log2FC hvDEGs found.
#> 883 Total hvDEGs found.
lengths(hv)
#> positive negative     both 
#>      475      408      883