calculate_conditional_celltype_enrichment_limma: Calculate celltype enrichments without MAGMA

View source: R/calculate_conditional_celltype_enrichment_limma.R

calculate_conditional_celltype_enrichment_limmaR Documentation

Calculate celltype enrichments without MAGMA

Description

Calculate celltype enrichments without MAGMA using adjusted MAGMA Z-statistic from .genes.out files.

Usage

calculate_conditional_celltype_enrichment_limma(
  magma1,
  magma2,
  ctd,
  ctd_species = infer_ctd_species(ctd),
  annotLevel = 1,
  prepare_ctd = TRUE,
  thresh = 1e-04,
  show_plot = TRUE,
  verbose = TRUE,
  ...
)

Arguments

magma1

Output from adjust_zstat_in_genesOut (e.g. trait 1).

magma2

Output from adjust_zstat_in_genesOut (e.g. trait 2).

ctd

Cell type data structure containing specificity_quantiles.

ctd_species

Species name relevant to the CellTypeDataset (ctd). See list_species for all available species. If ctd_species=NULL (default), the ctd species will automatically be inferred using infer_species.

annotLevel

Level within the ctd to use.

prepare_ctd

Whether to run prepare_quantile_groups on the ctd first.

thresh

A threshold on low specificity values (used to drop genes).

show_plot

Show plot visualizations of results (Default: TRUE).

verbose

Print messages.

...

Additional arguments passed to standardise_ctd.

Value

Data.frame with conditional enrichment results.

Examples

ctd <- ewceData::ctd()

#### MAGMA 1 #####
genesOut1 <- MAGMA.Celltyping::import_magma_files(
    ids = c("ieu-a-298"),
    file_types = ".genes.out",
    return_dir = FALSE)
magma1 <- MAGMA.Celltyping::adjust_zstat_in_genesOut(
    ctd = ctd, 
    magma_GenesOut_file = genesOut1)

#### MAGMA 2 #####
genesOut2 <- MAGMA.Celltyping::import_magma_files(
    ids = c("ukb-a-333"),
    file_types = ".genes.out",
    return_dir = FALSE)
magma2 <- MAGMA.Celltyping::adjust_zstat_in_genesOut(
    ctd = ctd, 
    magma_GenesOut_file = genesOut2)

#### Run conditional enrichment ####
cond_res <- 
MAGMA.Celltyping::calculate_conditional_celltype_enrichment_limma(
    magma1 = magma1,
    magma2 = magma2,
    ctd = ctd)

NathanSkene/MAGMA_Celltyping documentation built on Aug. 21, 2023, 8:55 a.m.