{"id":20665232,"url":"https://github.com/szcf-weiya/mtwas","last_synced_at":"2025-09-14T04:28:27.826Z","repository":{"id":209570618,"uuid":"701429934","full_name":"szcf-weiya/MTWAS","owner":"szcf-weiya","description":"R package for \"Multi-tissue Transcriptome-Wide Association Studies (MTWAS)\"","archived":false,"fork":false,"pushed_at":"2025-08-15T02:22:18.000Z","size":8035,"stargazers_count":15,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-15T04:19:00.198Z","etag":null,"topics":["eqtl","multi-tissue","twas"],"latest_commit_sha":null,"homepage":"https://hohoweiya.xyz/MTWAS/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szcf-weiya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-06T16:02:07.000Z","updated_at":"2025-08-15T02:16:21.000Z","dependencies_parsed_at":"2023-11-28T04:29:51.215Z","dependency_job_id":"72a7d41f-0824-4bd6-aa15-5603599f20b9","html_url":"https://github.com/szcf-weiya/MTWAS","commit_stats":null,"previous_names":["szcf-weiya/mtwas"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/szcf-weiya/MTWAS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szcf-weiya%2FMTWAS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szcf-weiya%2FMTWAS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szcf-weiya%2FMTWAS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szcf-weiya%2FMTWAS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szcf-weiya","download_url":"https://codeload.github.com/szcf-weiya/MTWAS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szcf-weiya%2FMTWAS/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275062851,"owners_count":25398886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eqtl","multi-tissue","twas"],"created_at":"2024-11-16T19:29:16.994Z","updated_at":"2025-09-14T04:28:27.812Z","avatar_url":"https://github.com/szcf-weiya.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MTWAS: Multi-tissue Transcriptome-Wide Association Studies\n\nMTWAS is an R package for the paper\n\n\u003e Song, S., Wang, L., Hou, L., \u0026 Liu, J. S. (2024). Partitioning and aggregating cross-tissue and tissue-specific genetic effects to identify gene-trait associations. Nature Communications, 15(1), 5769. https://doi.org/10.1038/s41467-024-49924-4\n\n\n:bulb: We provide pre-trained eQTL weights with MTWAS on 47 **GTEx version 8** tissues, 13 types of immune cells and 2 activation conditions of the **DICE** dataset, and 14 immune cell types from the single-cell RNA-seq **OneK1K** dataset.\n\n:smiley: You could either run MTWAS with the pre-trained weights (:star:easy and recommended), or train your own models with the expression data!\n\n## Table of contents\n* [Prerequisites](#white_check_mark-prerequisites)\n* [Installation](#hammer_and_wrench-installation)\n* [Prepare GWAS summary statistics](#scroll-prepare-gwas-summary-statistics)\n* [Run MTWAS with pre-trained GTEx v8 weights](#rocket-run-mtwas-with-pre-trained-gtex-v8-weights)\n* [Run MTWAS with pre-trained DICE weights](#rocket-run-mtwas-with-pre-trained-dice-weights)\n* [Run MTWAS with pre-trained OneK1K weights](#rocket-run-mtwas-with-pre-trained-onek1k-weights)\n* [Train MTWAS with your own datasets](#key-train-your-own-weights)\n\n\n## :white_check_mark: Prerequisites\n\nThe software is developed and tested in Linux and Windows environments.\n\n- R (\u003e=3.6)\n- GNU Scientific Library (GSL) (\u003e=2.3)\n\n## :hammer_and_wrench: Installation\n\n```r\ndevtools::install_github(\"szcf-weiya/MTWAS\")\n```\n\n## :scroll: Prepare GWAS summary statistics\nPlease prepare the GWAS summary statistics in the following format (including the header line):\n```\n   chr        rsid     ref   alt       z         \n    1      rs4040617    G     A     -0.199    \n    1      rs4075116    C     T      0.646     \n    1      rs9442385    T     G     -0.016    \n    ...\n```\n**chr**: chromosome\n\n**rsid**: SNP rsid\n\n**ref**: reference allele\n\n**alt**: alternative allele\n\n**z**: GWAS z score\n\n\n## :rocket: Run MTWAS with pre-trained GTEx v8 weights\n\n\n### Download the pre-trained files:\n\n```bash\nwget -O gtex_v8_mtwas_eqtls.tar.gz \"https://cloud.tsinghua.edu.cn/d/8bf84211cf3247a0b480/files/?p=%2Fgtex_v8_mtwas_eqtls.tar.gz\u0026dl=1\" --no-check-certificate\ntar -zxvf gtex_v8_mtwas_eqtls.tar.gz\n```\n\nIf you are working on UKBB phenotypes, please download from the following weights instead (We restricted eQTLs within UKBB SNPs):\n\n```bash\nwget -O gtex_v8_mtwas_eqtls.tar.gz \"https://cloud.tsinghua.edu.cn/d/8bf84211cf3247a0b480/files/?p=%2Fgtex_v8_mtwas_eqtls_ukbb.tar.gz\u0026dl=1\" --no-check-certificate\ntar -zxvf gtex_v8_mtwas_eqtls.tar.gz\n```\nThe result table for UKBB phenotypes (including 84 self-reported cancer and non-cancer illness phenotypes with effective sample sizes larger than 5,000) can also be directly downloaded from the supplementary files of the paper.\n\n### MTWAS analysis:\n\nWe use chromosome 22 on whole blood as an example. The list of tissues is detailed in `ct_use.RData`.\n\n```r\nlibrary(MTWAS)\ndata(\"summary_stats\") ## EXAMPLE GWAS summary stats (could be specified by users, format: a data.frame with colnames: chr, rsid, a1, a2, z)\nchr = 22\ncell_type = 'Whole_Blood'\n### remember to change the path to the downloaded folder!!!\n## load twas bim files (downloaded)\nload(paste0('./gtex_v8_mtwas_eqtls/twas_bim_chr', chr, '.RData'))  \n## load twas eqtl files (downloaded)\nload(paste0('./gtex_v8_mtwas_eqtls/', cell_type, '/twas_eqtl_chr', chr, '.RData'))\n## Run mtwas and derive the gene-trait association test statistics\nresults = run_mtwas_easy(summary_stats, twas_bim, twas_eqtl, pred_res) \nhead(results)\n```\n\nThe output `results` is a data.frame with the following format:\n\n```\n   gene        MTWAS_Z      MTWAS_P     pred_r2      pred_pv         \n  PLA2G3        -1.87        0.062        0.01        0.02    \n  PANX2         -1.83        0.066        0.01        0.08     \n    ...\n```\n\n**gene**: gene name\n\n**MTWAS_Z**: gene-trait association Z score derived by MTWAS\n\n**MTWAS_P**: gene-trait association P value derived by MTWAS\n\n**pred_r2**: prediction accuracy of the gene expression evaluated by $r^2$\n\n**pred_pv**: prediction accuracy of the gene expression evaluated by an F-test\n\nNote that we output results of all genes. Users could specify the criteria of the outputs, e.g.,`results[results$pred_pv \u003c 0.05 \u0026 results$MTWAS_P \u003c 5e-6, ]`.\n\n## :rocket: Run MTWAS with pre-trained DICE weights\n\n\n\n### Download the pre-trained files:\n\n```bash\nwget -O dice_mtwas_eqtls.tar.gz \"https://cloud.tsinghua.edu.cn/d/8bf84211cf3247a0b480/files/?p=%2Fdice_mtwas_eqtls.tar.gz\u0026dl=1\" --no-check-certificate\ntar -zxvf dice_mtwas_eqtls.tar.gz\n```\n\n\n### MTWAS analysis:\n\nWe use chromosome 22 on B naive cell line as an example. The list of cell types is detailed in `ct_use.RData` (remember to change the path to the downloaded folder).\n\n```r\nlibrary(MTWAS)\ndata(\"summary_stats\") ## EXAMPLE GWAS summary stats (could be specified by users, format: a data.frame with colnames: chr, rsid, a1, a2, z)\nchr = 22\ncell_type = 'B_NAIVE'\n### remember to change the path to the downloaded folder!!!\n## load twas bim files (downloaded)\nload(paste0('./dice_mtwas_eqtls/twas_bim_chr', chr, '.RData'))  \n## load twas eqtl files (downloaded)\nload(paste0('./dice_mtwas_eqtls/', cell_type, '/twas_eqtl_chr', chr, '.RData'))\n## Run mtwas and derive the gene-trait association test statistics\nresults = run_mtwas_easy(summary_stats, twas_bim, twas_eqtl, pred_res) \nhead(results)\n```\n\nThe output `results` is a data.frame with the following format:\n\n```\n   gene                 MTWAS_Z      MTWAS_P     pred_r2      pred_pv         \n  ENSG00000232754         3.08        0.002        0.04        0.99    \n  ENSG00000100225         2.46        0.014        0.07        0.01     \n    ...\n```\n\n**gene**: gene name\n\n**MTWAS_Z**: gene-trait association Z score derived by MTWAS\n\n**MTWAS_P**: gene-trait association P value derived by MTWAS\n\n**pred_r2**: prediction accuracy of the gene expression evaluated by $r^2$\n\n**pred_pv**: prediction accuracy of the gene expression evaluated by an F-test\n\nNote that we output results of all genes. Users could specify the criteria of the outputs, e.g.,`results[results$pred_pv \u003c 0.05 \u0026 results$MTWAS_P \u003c 5e-6, ]`.\n\n\n## :rocket: Run MTWAS with pre-trained OneK1K weights\n\n\n### Download the pre-trained files:\n\n```bash\nwget -O onek1k_mtwas_eqtls.tar.gz \"https://cloud.tsinghua.edu.cn/d/8bf84211cf3247a0b480/files/?p=%2Fonek1k_mtwas_eqtls.tar.gz\u0026dl=1\" --no-check-certificate\ntar -zxvf onek1k_mtwas_eqtls.tar.gz\n```\n\n\n### MTWAS analysis:\n\nWe use chromosome 22 on CD4 NC cell line as an example. The list of cell types is detailed in `ct_use.RData` (remember to change the path to the downloaded folder).\n\n```r\nlibrary(MTWAS)\ndata(\"summary_stats\") ## EXAMPLE GWAS summary stats (could be specified by users, format: a data.frame with colnames: chr, rsid, a1, a2, z)\nchr = 22\ncell_type = 'CD4_NC'\n### remember to change the path to the downloaded folder!!!\n## load twas bim files (downloaded)\nload(paste0('./onek1k_mtwas_eqtls/twas_bim_chr', chr, '.RData'))  \n## load twas eqtl files (downloaded)\nload(paste0('./onek1k_mtwas_eqtls/', cell_type, '/twas_eqtl_chr', chr, '.RData'))\n## Run mtwas and derive the gene-trait association test statistics\nresults = run_mtwas_easy(summary_stats, twas_bim, twas_eqtl, pred_res) \nhead(results)\n```\n\nThe output `results` is a data.frame with the following format:\n\n```\n   gene           MTWAS_Z      MTWAS_P     pred_r2      pred_pv         \n  APOL6            1.80        0.072        0.001        0.65    \n  RP6-109B7.3     -1.77        0.076        0.038       7.4e-09     \n    ...\n```\n\n**gene**: gene name\n\n**MTWAS_Z**: gene-trait association Z score derived by MTWAS\n\n**MTWAS_P**: gene-trait association P value derived by MTWAS\n\n**pred_r2**: prediction accuracy of the gene expression evaluated by $r^2$\n\n**pred_pv**: prediction accuracy of the gene expression evaluated by an F-test\n\nNote that we output results of all genes. Users could specify the criteria of the outputs, e.g.,`results[results$pred_pv \u003c 0.05 \u0026 results$MTWAS_P \u003c 5e-6, ]`.\n\n\n\n## :key: Train your own weights\n\nWe also provide functions to train MTWAS with your own datasets!\n\n### Step 1: Data preparation\n\nIn order to derive your own MTWAS weights, three types of data are necessary. There is a demo dataset built in our R package:\n\n```r\nlibrary(MTWAS)\ndata('demo')\n# demo$dat\n# demo$E.info\n# demo$E\n```\n\n#### (1) Genotype files (dat)\n\nFormat: a **list** of plink bfiles, including bim, fam, bed\n\nOne could use the R function `read_plink` in package `EBPRS` to read the plink files:\n\n```r\nlibrary(EBPRS)\ndat \u003c- read_plink('PATH_TO_PLINK_BFILE')\n```\n\n#### (2) Gene information (E.info)\n\nGenes that we are interested in to derive the gene-trait associations. \n\nFormat: a **data.frame** in the following format (including the header line):\n\n```\n   chr        start        end        gene         \n    22      15528192    15529139     OR11H1   \n    22      15690026    15721631     POTEH          \n    ...\n```\n\n#### (3) Gene expression data (E)\n\nA **list** including all the **gene expression data**, the length of the list is the number of tissues. Each element is a sample*gene matrix. \n\nEach matrix should have **rownames** (overlapped with `dat$fam$V2`), and **colnames** (overlapped with `E.info$gene`)\n\nThe orders of the columns and rows of the matrices are not necessary to be the same. The matrices can have NAs.\n\n:exclamation: Please NOTE that the position of `dat$bim$V4` and `E.info` should be the same build (e.g., both are hg19, or hg38, or etc.)\n\n\n### Step 2: Data imputation and formatting\n```r\nlibrary(MTWAS)\ndata('demo')\n### substitute the input with your own dataset\ntwas_dat \u003c- format_twas_dat(E=demo$E, E.info=demo$E.info, dat=demo$dat) \nnames(twas_dat)\n```\n\n### Step 3: Model training\n\n```r\n# load TWAS data\n# select cross-tissue eQTLs\nct.eQTL = select.ct.eQTL(twas_dat, verbose = F, ncores = 1)\n# select tissue-specific eQTLs\nlist.eQTL = select.ts.eQTL(twas_dat, ct.eQTL = ct.eQTL, ncores = 1)\n```\n\n### Step 4: Extract cross-tissue eQTLs\n\n```r\ngene_name = 'IL17RA' ## gene name\ngene_index = which(names(ct.eQTL)==gene_name)\n## ct-eQTLs for gene IL17RA\nprint(list.eQTL[[1]][[gene_index]]$`common.snp`) \n```\n\n### Step 5: Extract tissue-specific eQTLs\n\n```r\ngene_name = 'CCT8L2' ## gene name\ngene_index = which(names(ct.eQTL)==gene_name)\ntissue_index = 1 ## tissue specific\n## ts-eQTLs for gene CCT8L2 on tissue 1\nprint(list.eQTL[[tissue_index]][[gene_index]]$`single.snp`)\n```\n\n### Step 6: Gene-trait association tests\n\n```r\n# load GWAS summary statistics (data.frame, colnames: rsid, a1, a2, chr, z)\ndata(\"summary_stats\")\n# association test\ntwas.single.trait(summary_stats, twas_dat, list.eQTL)\n```\n\nThe details of output and data formats can be found in the auto-generated vignette: https://hohoweiya.xyz/MTWAS/articles/mtwas.html\n\n## References\n**MTWAS software**\n\u003e Song, S., Wang, L., Hou, L., \u0026 Liu, J. S. (2024). Partitioning and aggregating cross-tissue and tissue-specific genetic effects to identify gene-trait associations. Nature Communications, 15(1), 5769. https://doi.org/10.1038/s41467-024-49924-4\n\n**The GTEx dataset**\n\u003e https://gtexportal.org/home/\n\n**The DICE dataset**\n\u003e https://dice-database.org/\n\n\u003e Schmiedel, Benjamin J., et al. \"Impact of genetic polymorphisms on human immune cell gene expression.\" Cell 175.6 (2018): 1701-1715.\n\n**The OneK1K dataset**\n\u003e https://onek1k.org/\n\n\u003e Yazar, Seyhan, et al. \"Single-cell eQTL mapping identifies cell type–specific genetic control of autoimmune disease.\" Science 376.6589 (2022): eabf3041.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszcf-weiya%2Fmtwas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszcf-weiya%2Fmtwas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszcf-weiya%2Fmtwas/lists"}