Skip to contents

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.

Usage

expressed(object, condition, fdr = 0.05, which = "any")

Arguments

object

A DamIDResults object. This object must have been generated from data loaded with load_data_genes(calculate_fdr = 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'.

Value

A data.frame containing the gene_name and gene_id of genes that pass the filter.

Examples

# Helper function to create a sample DamIDResults object with FDR data
.generate_fdr_example_results <- function() {
    occupancy_df <- data.frame(
        gene_name = c("geneA", "geneB", "geneC"),
        gene_id = c("FBgn01", "FBgn02", "FBgn03"),
        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")
    new("DamIDResults",
        analysis = data.frame(row.names = rownames(occupancy_df)),
        upCond1 = data.frame(), upCond2 = data.frame(),
        cond = c("L4 Neurons" = "L4", "L5 Neurons" = "L5"),
        data = diff_results_base
    )
}
mock_fdr_results <- .generate_fdr_example_results()

# Get genes expressed in L4 neurons (FDR <= 0.05 in any replicate)
expressed(mock_fdr_results, condition = "L4 Neurons")
#> Found 2 FDR columns for condition 'L4 Neurons': L4_rep1_FDR, L4_rep2_FDR
#> 3 genes/loci passed the FDR <= 0.05 filter for condition 'L4 Neurons' with rule 'any'.
#>       gene_name gene_id avg_occ min_fdr
#> geneA     geneA  FBgn01     NaN    0.01
#> geneB     geneB  FBgn02     NaN    0.02
#> geneC     geneC  FBgn03     NaN    0.04

# Get genes expressed in L5 neurons with a stricter fdr
expressed(mock_fdr_results, condition = "L5", fdr = 0.02)
#> Found 1 FDR columns for condition 'L5': L5_rep1_FDR
#> 1 genes/loci passed the FDR <= 0.02 filter for condition 'L5' with rule 'any'.
#>       gene_name gene_id avg_occ min_fdr
#> geneC     geneC  FBgn03     NaN    0.01