A method to filter genes or loci that are considered 'expressed'
in a specific condition, based on a False Discovery Rate (FDR) threshold.
The method is a wrapper around the filter_genes_by_fdr function.
Arguments
- object
A
DamIDResultsobject. This object must have been generated from data loaded withload_data_genes(calculate_occupancy_pvals = TRUE)for the underlying FDR columns to be present.- condition
A character string identifying the experimental condition to filter. This can be the internal identifier or the user-friendly display name.
- fdr
Numeric. The FDR cutoff. Defaults to 0.05.
- which
Character string, either 'any' or 'all'. Determines whether a gene must pass the FDR threshold in any or all replicates of the condition. Defaults to 'any'.
Examples
.generate_fdr_example_results <- function() {
occupancy_df <- data.frame(
gene_name = c("geneA", "geneB", "geneC"),
gene_id = c("FBgn01", "FBgn02", "FBgn03"),
L4_rep1 = c(1.5, 0.2, 0.8),
L4_rep2 = c(1.7, 0.9, 0.1),
L5_rep1 = c(0.1, 0.1, 2.0),
L4_rep1_FDR = c(0.01, 0.10, 0.04),
L4_rep2_FDR = c(0.03, 0.02, 0.50),
L5_rep1_FDR = c(0.80, 0.90, 0.01),
row.names = c("geneA", "geneB", "geneC")
)
diff_results_base <- list(
occupancy = occupancy_df,
test_category = "expressed",
matched_samples = list("L4" = c("L4_rep1", "L4_rep2"), "L5" = "L5_rep1")
)
new("DamIDResults",
analysis = data.frame(row.names = rownames(occupancy_df)),
upCond1 = data.frame(),
upCond2 = data.frame(),
cond = c("L4 mock" = "L4", "L5 mock" = "L5"),
data = diff_results_base
)
}
mock_fdr_results <- .generate_fdr_example_results()
# Get expressed in a condition (FDR <= 0.05)
expressed(mock_fdr_results, condition = "L4 mock")
#> 3 genes passed the FDR filter using rule 'any'.
#> gene_name gene_id avg_occ fdr_val
#> geneA geneA FBgn01 1.60 0.01
#> geneB geneB FBgn02 0.55 0.02
#> geneC geneC FBgn03 0.45 0.04
# Get genes expressed with a more stringent FDR (<= 0.01)
expressed(mock_fdr_results, condition = "L4", fdr = 0.01)
#> 1 genes passed the FDR filter using rule 'any'.
#> gene_name gene_id avg_occ fdr_val
#> geneA geneA FBgn01 1.6 0.01