{"id":13593130,"url":"https://github.com/yanwu2014/swne","last_synced_at":"2025-04-09T02:32:39.512Z","repository":{"id":185719257,"uuid":"116182670","full_name":"yanwu2014/swne","owner":"yanwu2014","description":"Similarity Weighted Nonnegative Embedding (SWNE), a method for visualizing high dimensional datasets","archived":false,"fork":false,"pushed_at":"2023-08-02T22:57:11.000Z","size":221444,"stargazers_count":103,"open_issues_count":3,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-08-02T16:46:45.917Z","etag":null,"topics":["bioinformatics","data-visualization","dimensionality-reduction","nonnegative-matrix-factorization","single-cell-analysis","single-cell-atac-seq","single-cell-genomics","single-cell-rna-seq","statistical-methods"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yanwu2014.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}},"created_at":"2018-01-03T21:15:10.000Z","updated_at":"2024-06-08T00:44:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c8488d0-0be4-49b0-b5f7-924e9eb5801c","html_url":"https://github.com/yanwu2014/swne","commit_stats":null,"previous_names":["yanwu2014/swne"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanwu2014%2Fswne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanwu2014%2Fswne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanwu2014%2Fswne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanwu2014%2Fswne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yanwu2014","download_url":"https://codeload.github.com/yanwu2014/swne/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223356585,"owners_count":17132165,"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","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":["bioinformatics","data-visualization","dimensionality-reduction","nonnegative-matrix-factorization","single-cell-analysis","single-cell-atac-seq","single-cell-genomics","single-cell-rna-seq","statistical-methods"],"created_at":"2024-08-01T16:01:16.872Z","updated_at":"2024-11-06T14:31:16.304Z","avatar_url":"https://github.com/yanwu2014.png","language":"R","funding_links":[],"categories":["Software packages","R"],"sub_categories":["RNA-seq","Dimension reduction"],"readme":"# SWNE\nSimilarity Weighted Nonnegative Embedding (SWNE), is a method for visualizing high dimensional datasets.\nSWNE uses Nonnegative Matrix Factorization to decompose datasets into latent factors, projects\nthose factors onto 2 dimensions, and embeds samples and key features in 2 dimensions relative to the\nfactors. SWNE can capture both the local and global dataset structure, and allows\nrelevant features to be embedded directly onto the visualization, helping with biological interpretation.\n\nIf you use SWNE in your research, please cite [Wu et al, Cell Systems, 2018](https://doi.org/10.1016/j.cels.2018.10.015)\n\n## Installation\nRun the following code to install the package using devtools:\n\n```\nif(!require(remotes)){ install.packages(\"remotes\") # If not already installed; }\nremotes::install_github(\"linxihui/NNLM\")\nremotes::install_github(\"yanwu2014/swne\")\n```\n\nIf you want to run SWNE on chromatin accessibility data, install [cisTopic](github.com/aertslab/cisTopic) as well.\n\n```\ndevtools::install_github(\"aertslab/RcisTarget\")\ndevtools::install_github(\"aertslab/AUCell\")\ndevtools::install_github(\"aertslab/cisTopic\")\n```\n\n\n## Key Updates\n*(10/21/2019): Improve SWNE embeddings by using PAGA graphs to prune the SNN graph. Update factor embedding distance function.\n\n*(09/19/2019): The wrapper function `RunSWNE` now works on integrated Seurat datasets\n\n*(05/15/2019): Updated all code and vignettes for Seurat V3 objects. Removed C1/snDropSeq projection vignette since it's easier to use Seurat data integration (or CONOS)\n\n\n## Gene Expression Quickstart with Seurat\nDownload the example [Seurat object](https://bit.ly/2W3pT7k) which contains single cell RNA-seq profiles of 3000 PBMCs\n\n```\n## Load object\nobj \u003c- readRDS(\"Data/pbmc3k_final.RObj\")\n\n## Extract clusters\nclusters \u003c- obj$seurat_clusters\n\n## Select genes to embed\ngenes.embed \u003c- c(\"MS4A1\", \"GNLY\", \"CD3E\", \"CD14\",\n                 \"FCER1A\", \"FCGR3A\", \"LYZ\", \"PPBP\", \"CD8A\")\n\n## Run SWNE\nswne.embedding \u003c- RunSWNE(obj, k = 16, genes.embed = genes.embed)\n\n## Plot SWNE\nPlotSWNE(swne.embedding, alpha.plot = 0.4, sample.groups = clusters,\n         do.label = T, label.size = 3.5, pt.size = 1.5, show.legend = F,\n         seed = 42)\n```\n\n![](Examples/seurat_quickstart_swne.png?raw=True \"SWNE plot of 3k PBMCs\")\n\n\n## Chromatin Accessibility Quickstart with cisTopic\nSWNE's chromatin accessibility visualizations currently only work with [cisTopic]((https://github.com/aertslab/cisTopic)), a great method by [Gonazalez-Blas et al](https://www.nature.com/articles/s41592-019-0367-1) that uses LDA to decompose scATAC or scTHS datasets. Download the example [cisTopic object](https://bit.ly/2HnClXK) which contains single cell THS-seq profiles of 14,535 human brain cells from [Lake, Sos, Chen et al, NBT, 2017](https://www.nature.com/articles/nbt.4038).\n\n\n```\nlibrary(cisTopic)\nlibrary(swne)\nlibrary(org.Hs.eg.db)\nlibrary(TxDb.Hsapiens.UCSC.hg38.knownGene)\n\n## Load data\ncisTopicObject \u003c- readRDS(\"Data/adult-vCTX_cisTopic.RObj\")\n\n## Pull out clusters\nclusters \u003c- cisTopicObject@other$clusters\n\n## Annotate regions\ncisTopicObject \u003c- getRegionsScores(cisTopicObject)\ncisTopicObject \u003c- annotateRegions(cisTopicObject, txdb = TxDb.Hsapiens.UCSC.hg38.knownGene,\n                                  annoDb = \"org.Hs.eg.db\")\n\n## Run SWNE embedding\nswne.emb \u003c- RunSWNE(cisTopicObject, alpha.exp = 1.25, snn.exp = 1, snn.k = 30)\n\n## Embed genes based on promoter accessibility\nmarker.genes \u003c- c(\"CUX2\", \"RORB\", \"FOXP2\", \"FLT1\", \"GAD1\", \"SST\", \"SLC1A2\", \"MOBP\", \"P2RY12\")\nswne.emb \u003c- EmbedPromoters(swne.embedding, cisTopicObject, genes.embed = marker.genes,\n                           peaks.use = NULL, alpha.exp = 1, n_pull = 3)\n\nPlotSWNE(swne.emb, sample.groups = clusters, pt.size = 0.5, alpha.plot = 0.5, do.label = T,\n         seed = 123)\n```\n\n![](Examples/cisTopic_quickstart_swne.png?raw=True \"SWNE plot of chromatin accessibility for 15k brain cells\")\n\n\n## scRNA-seq Walkthroughs and examples\nSince SWNE is primarily meant for visualization and interpretation of the data, we typically use either [Seurat](http://satijalab.org/seurat/) or [Pagoda2](https://github.com/hms-dbmi/pagoda2) as a primary scRNA-seq pipeline. All the R markdown files used to generate the walkthroughs can be found under the Examples/ directory.\n\n1. A basic [walkthrough](https://yanwu2014.github.io/swne/Examples/pbmc3k_swne_seurat.html) using SWNE to visualize 3k PBMC cells starting from a pre-computed Seurat object\n2. A basic [walkthrough](https://yanwu2014.github.io/swne/Examples/pbmc3k_swne_pagoda2.html) using SWNE to visualize 3k PBMC cells starting from a pre-computed Pagoda2 object\n3. A basic [walkthrough](https://yanwu2014.github.io/swne/Examples/pbmc3k_swne_matrix.html) using SWNE to visualize 3k PBMC cells starting from a counts matrix\n4. A [walkthrough](https://yanwu2014.github.io/swne/Examples/Han_hemato_swne.html) benchmarking SWNE against UMAP and SWNE using a large mouse hematopoiesis data from the [Mouse Cell Atlas](http://bis.zju.edu.cn/MCA/). The walkthrough was based of an analysis done by the UMAP authors in Figure 2 of their UMAP paper [Becht, McInnes et al, NBT, 2019](https://www.nature.com/articles/nbt.4314).\n5. A [walkthrough](https://yanwu2014.github.io/swne/Examples/hemato_swne.html) demonstrating SWNE on a hematopoiesis dataset and comparing SWNE against other embeddings including t-SNE and UMAP (recreating Figure 2 from our Cell Systems paper).\n6. A [walkthrough](https://yanwu2014.github.io/swne/Examples/zika_swne.html) demonstrating SWNE on a single-cell [study](https://elifesciences.org/articles/32942) looking at Zika replication across time in a hepatoma cell line.\n7. A [walkthrough](https://yanwu2014.github.io/swne/Examples/multiple_pancreas_alignment_swne.html) using SWNE to visualize four pancreas datasets that have undergone alignment with Seurat V3's [data integration](https://doi.org/10.1016/j.cell.2019.05.031).\n\n\n## scATAC/THS-seq Walkthroughs and examples\nSince SWNE is primarily meant for visualization and interpretation of the data, we typically use either [cisTopic](http://satijalab.org/seurat/) as a primary pipeline\n\n1. A [walkthrough](https://yanwu2014.github.io/swne/Examples/scATAC_hemato_swne.html) using SWNE to visualize a hematopoiesis trajectory that illustrates how to embed both the promoter accessibility of genes, and the binding site accessibility of transcription factors.\n\n\n## Recreating Figures\nTo recreate the figures from our preprint, see the `Scripts/` directory. \n\nTo generate the simulated discrete and trajectory datasets, use `splatter_generate.R`. The simulated datasets we generated can be found [here](https://bit.ly/2JQDDNc)\n\nTo generate the visualizations and embedding evaluations, run `splatter_discrete_swne.R` and `splatter_trajectory_swne.R` for the discrete and trajectory simulations, respectively. To benchmark SWNE runtimes, use `splatter_runtime_analysis.R`.\n\nThe data needed to run `hemato_swne.R` can be found [here](https://bit.ly/2MFiByO) and the raw data for the hematopoietic cells can be found, courtesy of the monocle2 developers, [here](http://www.gs.washington.edu/~xqiu/proj2/RGE_analysis_data.tar.gz). The `hemato_swne.R` script is also available as a [SWNE walkthrough](https://yanwu2014.github.io/swne/Examples/hemato_swne.html).\n\nThe data needed to run `snDropSeq_swne.R` on the cerebellar and visual cortex data can be found [here](https://bit.ly/2I6R5XL) and the raw data can be found at the GEO accession GSE97930.\n\nThe raw PBMC dataset can be found at the 10X genomics [website](https://support.10xgenomics.com/single-cell-gene-expression/datasets/1.1.0/pbmc3k).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanwu2014%2Fswne","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyanwu2014%2Fswne","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanwu2014%2Fswne/lists"}