Last updated: 2024-09-25

Checks: 7 0

Knit directory: lung_lymph_scMultiomics/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20221229) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 32e347d. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory

Untracked files:
    Untracked:  analysis/.ipynb_checkpoints/
    Untracked:  analysis/GOBP_B_CELL_ACTIVATION_INVOLVED_IN_IMMUNE_RESPONSE.v2024.1.Hs.gmt
    Untracked:  analysis/test.pdf
    Untracked:  analysis/test_GO_enrichment.ipynb
    Untracked:  analysis/u19_atac_fastTopics.Rmd
    Untracked:  analysis/u19_regulon_enrichment.Rmd
    Untracked:  analysis/ukb-a-446.log
    Untracked:  analysis/ukb-a-446_GO_immune.log
    Untracked:  code/run_magma/
    Untracked:  data/DA_peaks_Tsub_vs_others.RDS
    Untracked:  data/DA_peaks_by_cell_type.RDS
    Untracked:  data/TF_target_sizes_GRN.txt
    Untracked:  data/Tsuo2022_meta_analysis_asthma_risk_genes.csv
    Untracked:  data/U19_T_cell_peaks_metadata.RDS
    Untracked:  data/Wang_2020_T_cell_peaks_metadata.RDS
    Untracked:  data/lung_GRN_CD4_T_edges.txt
    Untracked:  data/lung_GRN_CD8_T_edges.txt
    Untracked:  data/lung_GRN_Th17_edges.txt
    Untracked:  data/lung_GRN_Treg_edges.txt
    Untracked:  output/annotation_reference.txt
    Untracked:  output/fastTopics
    Untracked:  output/homer/
    Untracked:  output/ldsc_enrichment
    Untracked:  output/lung_immune_atac_peaks_high_ePIPs.RDS
    Untracked:  output/positions.bed
    Untracked:  output/topic1/
    Untracked:  output/topic10/
    Untracked:  output/topic11/
    Untracked:  output/topic12/
    Untracked:  output/topic2/
    Untracked:  output/topic3/
    Untracked:  output/topic4/
    Untracked:  output/topic5/
    Untracked:  output/topic6/
    Untracked:  output/topic7/
    Untracked:  output/topic8/
    Untracked:  output/topic9/
    Untracked:  test.pdf

Unstaged changes:
    Modified:   analysis/cross_tissue_DE_u19_fastTopics.Rmd
    Modified:   analysis/identify_regulatory_programs_u19_GRN.Rmd
    Modified:   analysis/rank_TFs_from_pairwise_comparison.ipynb
    Modified:   analysis/u19_h2g_enrichment.Rmd
    Deleted:    code/run_fastTopic.R
    Deleted:    lung_immune_fine_mapping.Rproj

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/test_magma.Rmd) and HTML (docs/test_magma.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 32e347d Jing Gu 2024-09-25 gene-set association with magma
html 9f5d519 Jing Gu 2024-09-25 Build site.
Rmd 3b84e56 Jing Gu 2024-09-25 gene-set association with magma
html f649cf3 Jing Gu 2024-09-19 Build site.
Rmd 1e7e576 Jing Gu 2024-09-19 look into k5 genes with high z scores
html ab42a52 Jing Gu 2024-09-16 Build site.
Rmd a2b320f Jing Gu 2024-09-16 test topic enrichment for genetic risks

MAGMA

Gene analysis A linear principal component regression model that estimates whether there is genetic effect of gene g on the phenotype Y, conditional on all covariates. The model first projects genotype matrix for a gene g onto its PCs, pruning away PCs with very small eigenvalues. Then it performs F test in the regression of Y on SNP matrix and covariates to estimate genetic effect.

\[ Y = \alpha_{0g}\vec 1 + X_g^*\alpha_g + W\beta_g + \epsilon_g \] When inividual geneotype matrix not available, MAGMA performs gene test with mean \(X^2\) statistics and a gene p-value is then obtained by using a known approximation of the sampling distribution. Please refer to the following paper for details of approximation for the distribution of the weighted combination of p-values. This model requires summary statistics and reference LD panel.

Ref: Hou C (2005) A simple approximation for the distribution of the weighted combination of non-independent or independent probabilities. Stat Probabil Lett 73: 179–187.

Competitive gene-set analysis

One-sided Two-sample T test or linear regression in equivalence is applied to test whether the genes in a gene set are more strongly associated with Y or not.

Let Z denote the association z-score. Let \(\S_s\) be an indicator variable with element \(s_g = 1\) defined as for gene g in gene set s and 0 otherwise. The goal is to test whether \(\beta_s\) is greater than zero, which represents the difference in association between genes in the gene set and genes outside the gene set.

\[ Z = \beta_{0s}\vec 1 + S_s\beta_s + \epsilon \] This also be tested by unpaired two sample T-test, while two samples can have unequal variances and sample sizes.

Testrun

Procedure:

  1. annotate SNPs and genes
  2. gene-based analysis
  3. gene-set analysis

Gene-set associations for topic marker genes that are up-regulated

When corrected for multiple testing, tests will be significant if p-value lower than ~0.005. Around half of the tests show significant p-values, which makes us wonder if p-values are inflated. Then we try using the input genes for topic modeling rather than all genes as background so that they are more comparable.

  • Total number of genes reduced from to 18K to ~16K
  • P values for the reduced background genes are very similar to the full ones.

Version Author Date
ab42a52 Jing Gu 2024-09-16

Test enrichment using top 100 genes from each topic

The supplementary table from MAGMA paper shows the mean type 1 error rates are well controlled for a set of size 100. The MSigDB canonical pathways contains 1320 gene sets from a number of different databases. I can look into the average size of the gene sets. MAGMA controlling for type 1 error rates for gene-set analysis

Instead of all DE genes, I used top 100 up-regulated genes ranked by z scores to test the enrichment for each topic. Now we see only k3, k4, k5 and k12 (4/12) topics show significant enrichment after multiple testing correction.

Check the top genes contributing to topic 5 that have high MAGMA Z-scores

Genes with high Z-scores (p < 0.05) are found to show enrichment in the following gene sets:

  • Regulation of signal transduction (adj.P = 0.01) from GO
    • RORA, GATA3, CDC42SE2, SREBF2
  • Interleukin-2 signaling pathway (adj.P = 0.003) from BioPlanet
    • CD247, RORA, GATA3, TAB2, FOXO1,IL21R, YARS (overlapping genes)
  • Th17 Cell Differentiation (adj.P = 0.0002) and IBD (adj.P = 0.001) from KEGG
    • CD247, RORA, GATA3,IL21R
Joining with `by = join_by(GENE)`

Check the top genes contributing to topic 3 that have high MAGMA Z-scores

Genes with high Z-scores (p < 0.05) are found to show enrichment in the following GO terms:

1 Alpha-Beta T Cell Activation (GO:0046631) 0.00007389 0.007163 204.61 1946.45. 2 Regulation Of Natural Killer Cell Activation (GO:0032814) 0.0001340 0.007163 146.12 1303.03.
3 Regulation Of Lymphocyte Activation (GO:0051249) 0.0001706 0.007163 127.84 1109.13.
4 Stimulatory C-type Lectin Receptor Signaling Pathway (GO:0002223) 0.0001906 0.007163 120.31 1030.52.
5 Cellular Response To Lectin (GO:1990858) 0.0001906 0.007163 120.31 1030.52.
6 Antigen Receptor-Mediated Signaling Pathway (GO:0050851) 0.0002146 0.007163 30.59 258.42.
7 Positive Regulation Of Natural Killer Cell Mediated Cytotoxicity (GO:0045954) 0.0002337 0.007163 107.63 899.96.
8 Natural Killer Cell Mediated Immunity (GO:0002228) 0.0002570 0.007163 102.25 845.24.
9 Positive Regulation Of Natural Killer Cell Mediated Immunity (GO:0002717) 0.0003066 0.007597 92.94 751.89.
10 Innate Immune Response Activating Cell Surface Receptor Signaling Pathway (GO:0002220) 0.0003892 0.008678 81.77 642.05.

Joining with `by = join_by(GENE)`

Check the top genes contributing to topic 4 that have high MAGMA Z-scores

Genes with high Z-scores (p < 0.05) are found to show enrichment in the following GO terms:

1 Regulation Of Blood Vessel Endothelial Cell Migration (GO:0043535) | 0.0006701 | AKT3, PRKCA, TNF, ETS1.
2 Antigen Receptor-Mediated Signaling Pathway (GO:0050851) | 0.006130 | CD28, BCL2, BTN3A3, SKAP1.
3 Positive Regulation Of Leukocyte Cell-Cell Adhesion (GO:1903039)| 0.006130 | TNF, ETS1, SKAP1.

Joining with `by = join_by(GENE)`

Gene-set associations for known immune cell markers

Most immune cell markers were obtained from Gene ontology. The tissue-resident genes were from the single-cell lung paper and ChatGPT. After multiple correction, tissue-resident markers do not show significance for the gene-set association with Asthma. Neither do the genes involved in cell-cell adhesion or cell migration. The gene sets that are significantly enriched for higher association with Asthma risks are activation of T/B cells and differentiation of T cell lineage differentiation.


R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el7-x86_64/lib/libopenblas_haswellp-r0.3.13.so

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C           
 [4] LC_COLLATE=C         LC_MONETARY=C        LC_MESSAGES=C       
 [7] LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.1.4       data.table_1.15.4 workflowr_1.7.1  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.12       highr_0.10        compiler_4.2.0    pillar_1.9.0     
 [5] bslib_0.7.0       later_1.3.2       git2r_0.33.0      jquerylib_0.1.4  
 [9] tools_4.2.0       getPass_0.2-2     digest_0.6.35     jsonlite_1.8.8   
[13] evaluate_0.23     lifecycle_1.0.4   tibble_3.2.1      pkgconfig_2.0.3  
[17] rlang_1.1.3       cli_3.6.2         rstudioapi_0.15.0 crosstalk_1.2.1  
[21] yaml_2.3.8        xfun_0.43         fastmap_1.1.1     withr_3.0.0      
[25] httr_1.4.7        stringr_1.5.1     knitr_1.46        htmlwidgets_1.6.4
[29] generics_0.1.3    fs_1.6.4          vctrs_0.6.5       sass_0.4.9       
[33] DT_0.33           tidyselect_1.2.1  rprojroot_2.0.4   glue_1.7.0       
[37] R6_2.5.1          processx_3.8.3    fansi_1.0.6       rmarkdown_2.26   
[41] callr_3.7.3       magrittr_2.0.3    whisker_0.4.1     ps_1.7.6         
[45] promises_1.3.0    htmltools_0.5.8.1 httpuv_1.6.14     utf8_1.2.4       
[49] stringi_1.7.6     cachem_1.0.8