calculate_conditional_celltype_associations: Calculate conditional celltype associations using MAGMA

View source: R/calculate_conditional_celltype_associations.R

calculate_conditional_celltype_associationsR Documentation

Calculate conditional celltype associations using MAGMA

Description

Run cell-type enrichment analysis on a GWAS previously mapped to genes (using map_snps_to_genes) while controlling for certain cell-types. This allows one to conduct cell-type enrichment analyses while controlling for the strongest cell-type-specific signatures. Which cell-types are controlled for can be specified by either of the following arguments:

  • controlTopNcellsAutomatically selects the top N mostly significantly enriched cell-types.

  • controlledCTsA user-provided list of cell-types present in the ctd.

Three sets of analyses are run:

  • Baseline enrichment resultsNo conditioning.

  • Conditional results: separate conditioning on each specified cell-type separately

  • Conditional results: grouped conditioning all specified cell-types at once.

Usage

calculate_conditional_celltype_associations(
  ctd,
  ctd_species = infer_ctd_species(ctd),
  gwas_sumstats_path = NULL,
  magma_dir = NULL,
  analysis_name = "MainRun",
  prepare_ctd = TRUE,
  upstream_kb = 35,
  downstream_kb = 10,
  controlledAnnotLevel = 1,
  controlTopNcells = NA,
  controlledCTs = NA,
  EnrichmentMode = "Linear",
  qvalue_thresh = 0.05,
  force_new = FALSE,
  version = NULL,
  verbose = TRUE
)

Arguments

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.

gwas_sumstats_path

File path of the summary statistics file.

magma_dir

Path to folder containing the pre-computed MAGMA GWAS files (.gsa.rawand .gsa.out).

analysis_name

Used in file names which area created.

prepare_ctd

Whether to run prepare_quantile_groups on the ctd first.

upstream_kb

How many kb upstream of the gene should SNPs be included?

downstream_kb

How many kb downstream of the gene should SNPs be included?

controlledAnnotLevel

Which annotation level should be controlled for.

controlTopNcells

How many of the most significant cell types at that annotation level should be controlled for?

controlledCTs

Array of the celltype to be controlled for, e.g. c('Interneuron type 16','Medium Spiny Neuron').

EnrichmentMode

[Optional] Should either 'Linear' or 'Top 10%' mode be used for testing enrichment?

qvalue_thresh

Multiple-testing corrected p-value threshold to filter by when determining which celltypes to condition with.

force_new

[Optional] Force new MAGMA analyses even if the pre-existing results files are detected.

version

MAGMA version to use.

verbose

Print messages.

Value

A concatenated results table containing:

  • Baseline enrichment results.

  • Conditional results: conditioning on each specified cell-type individually.

  • Conditional results: conditioning all specified cell-types at once.

Examples

#### Prepare cell-type data ####
ctd <- ewceData::ctd()
#### Prepare GWAS MAGMA data ####
magma_dir <- MAGMA.Celltyping::import_magma_files(ids = "ieu-a-298")
#### Run pipeline ####
ctAssocs <- calculate_conditional_celltype_associations(
    ctd = ctd,
    controlledAnnotLevel = 1,
    controlTopNcells = 1,
    qvalue_thresh = 1,
    magma_dir = magma_dir,
    ctd_species = "mouse", 
    force = TRUE) 

neurogenomics/MAGMA_Celltyping documentation built on Aug. 22, 2023, 7:18 a.m.