Skip to content

MAGMA_Celltyping

Barney Hill edited this page Aug 11, 2021 · 1 revision

MAGMA_Celltyping is a key tool developed by the lab and all computational lab members should be familiar with it's usage.

If you are new to working with GWAS summary statistics, it may help to read this description written by Michel Nivard: 2. Important resources and key information · MichelNivard/GenomicSEM Wiki

Setting it up on Imperial Cluster

Download the magma executable to a folder in your local directory, e.g. 'home/magma_v1.08a'

Now add that folder to your $PATH. Open your bash profile with vi ~/.bash_profile then add these lines to it:

export PATH=~/magma_v1.08a:$PATH
module load gcc/8.2.0

You'll need to run source ~/.bash_profile before running R for this to work.

Because RStudio doesn't load bash variables, you'll also want to add this to ~/.REnviron (but only the export PATH part, not module load).

Using for gene set enrichment on shared MAGMA files

We keep a shared set of precomputed MAGMA files at /projects/neurogenomics-lab/live/MAGMA_Files/. If you want to use these for a gene set enrichment, then here's some example code:

library(MAGMA.Celltyping)
storage_dir <- "~/Downloads"

# Set path the 1000 genomes reference data.
genome_ref_dir = file.path(storage_dir,"g1000_eur")
if(!file.exists(sprintf("%s/g1000_eur.bed",genome_ref_dir))){
    download.file("https://ctg.cncr.nl/software/MAGMA/ref_data/g1000_eur.zip",destfile=sprintf("%s.zip",genome_ref_dir))
    unzip(sprintf("%s.zip",genome_ref_dir),exdir=genome_ref_dir)
}
genome_ref_path = sprintf("%s/g1000_eur",genome_ref_dir)

data("rbfox_binding")

gwas_sumstats_path = "/rds/general/user/nskene/projects/neurogenomics-lab/live/ALS_2018.annotated"

geneset_res = calculate_geneset_enrichment(geneset=rbfox_binding,gwas_sumstats_path=gwas_sumstats_path,analysis_name="Rbfox_20016",upstream_kb=35,downstream_kb=10,genome_ref_path=genome_ref_path,geneset_species="mouse")

This example uses the ALS GWAS. Change the gwas_sumstats_path to switch to a different file. The original sum stats doesn't need to be there, just use the start of the folder name from within the MAGMA_Files folder, as was done for ALS_2018.annotated.

Note that you may need to change the upstream_kb and downstream_kb, depending on the MAGMA files used (look at the file names).

Clone this wiki locally