calculate_celltype_associations: Calculate celltype associations using MAGMA

View source: R/calculate_celltype_associations.r

calculate_celltype_associationsR Documentation

Calculate celltype associations using MAGMA

Description

Assumes that you have already run map_snps_to_genes.

Usage

calculate_celltype_associations(
  ctd,
  ctd_levels = seq_len(length(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,
  genesOutCOND = NA,
  EnrichmentMode = "Linear",
  force_new = FALSE,
  version = NULL,
  verbose = TRUE
)

Arguments

ctd

Cell type data structure containing specificity_quantiles.

ctd_levels

Which levels of ctd to iterate the enrichment analysis over.

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?

genesOutCOND

[Optional] Path to a genes.out file to condition on. Used if you want to condition on a different GWAS.

EnrichmentMode

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

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

File path for the genes.out file

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_celltype_associations(
    ctd = ctd,
    ctd_levels = 1,
    magma_dir = magma_dir,
    ctd_species = "mouse")

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