├── .DS_Store ├── .Rbuildignore ├── .github ├── no-response.yml └── workflows │ └── test-vignettes.yml ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── alevin.R ├── alra.R ├── banksy.R ├── cellbrowser.R ├── cogaps.R ├── conos.R ├── fast_mnn.R ├── fast_mnn_v5.R ├── glmpca.R ├── internal.R ├── liger.R ├── miqc.R ├── monocle3.R ├── pacmap.R ├── presto.R ├── scVI.R ├── tricycle.R └── velocity.R ├── README.md ├── docs ├── README.md ├── alevin.Rmd ├── alevin.html ├── alevin.md ├── alra.Rmd ├── alra.html ├── alra.md ├── alra_files │ └── figure-markdown_github │ │ └── explore-1.png ├── banksy.Rmd ├── banksy.md ├── banksy_files │ └── figure-gfm │ │ ├── hippo_gene-1.png │ │ ├── hippo_viz-1.png │ │ ├── hippo_viz-2.png │ │ ├── multi-spatial-1.png │ │ ├── multi-spatial-staggered-1.png │ │ ├── multi-umap-1.png │ │ ├── ss_markers-1.png │ │ └── ss_viz-1.png ├── cellbrowser.Rmd ├── cellbrowser.html ├── cellbrowser.md ├── cellbrowser.png ├── cipr.Rmd ├── cipr.html ├── cipr.md ├── cipr_files │ └── figure-gfm │ │ ├── unnamed-chunk-15-1.png │ │ ├── unnamed-chunk-16-1.png │ │ ├── unnamed-chunk-17-1.png │ │ ├── unnamed-chunk-18-1.png │ │ ├── unnamed-chunk-19-1.png │ │ ├── unnamed-chunk-20-1.png │ │ ├── unnamed-chunk-21-1.png │ │ ├── unnamed-chunk-22-1.png │ │ ├── unnamed-chunk-23-1.png │ │ ├── unnamed-chunk-24-1.png │ │ ├── unnamed-chunk-25-1.png │ │ ├── unnamed-chunk-26-1.png │ │ └── unnamed-chunk-9-1.png ├── cogaps.html ├── cogaps.md ├── cogaps.rmd ├── cogaps_files │ └── figure-markdown_github │ │ ├── tenPatternsBVlnPlot-1.png │ │ ├── tenPatternsDcVlnPlot-1.png │ │ ├── tenPatternsFcgr3aVlnPlot-1.png │ │ ├── tenPatternsScatterPlot-1.png │ │ ├── tenPatternsScatterPlot-2.png │ │ ├── tenPatternsScatterPlot-3.png │ │ ├── threePatternsExampleLympVlnPlot-1.png │ │ ├── threePatternsExampleMyeVlnPlot-1.png │ │ ├── threePatternsExampleScatterPlot-1.png │ │ ├── threePatternsLymphoidVlnPlot-1.png │ │ ├── threePatternsMyeloidVlnPlot-1.png │ │ └── threePatternsScatterPlot-1.png ├── conos.Rmd ├── conos.html ├── conos.md ├── conos_files │ └── figure-markdown_github │ │ ├── ifnb-1.png │ │ ├── pancreas-1.png │ │ └── pbmcsca-1.png ├── fast_mnn.Rmd ├── fast_mnn.html ├── fast_mnn.md ├── fast_mnn_files │ └── figure-gfm │ │ ├── ifnb_stim-1.png │ │ ├── pancreas-1.png │ │ └── pbmcsca-1.png ├── glmpca.Rmd ├── glmpca.html ├── glmpca.md ├── glmpca_files │ └── figure-markdown_github │ │ ├── explore-1.png │ │ └── explore2-1.png ├── harmony.Rmd ├── harmony.html ├── harmony.md ├── harmony_files │ └── figure-markdown_github │ │ ├── ifnb_stim-1.png │ │ ├── pancreas-1.png │ │ └── pbmcsca-1.png ├── liger.Rmd ├── liger.html ├── liger.md ├── liger_files │ └── figure-gfm │ │ ├── ifnb-1.png │ │ ├── pancreas-1.png │ │ └── pbmcsca-1.png ├── miQC.Rmd ├── miQC.html ├── miQC.md ├── miQC_files │ └── figure-gfm │ │ ├── unnamed-chunk-10-1.png │ │ ├── unnamed-chunk-11-1.png │ │ ├── unnamed-chunk-2-1.png │ │ ├── unnamed-chunk-5-1.png │ │ ├── unnamed-chunk-6-1.png │ │ ├── unnamed-chunk-8-1.png │ │ └── unnamed-chunk-9-1.png ├── monocle3.Rmd ├── monocle3.html ├── monocle3.md ├── monocle3_files │ └── figure-gfm │ │ ├── dimreduc_hca-1.png │ │ ├── integrated_dimplot-1.png │ │ ├── monocle3_clustering-1.png │ │ ├── pseudotime-1.png │ │ ├── pseudotime-2.png │ │ └── subset_partitions-1.png ├── nebulosa.Rmd ├── nebulosa.html ├── nebulosa.md ├── nebulosa_files │ └── figure-gfm │ │ ├── cd4_and_clustering-1.png │ │ ├── cd4_comparison-1.png │ │ ├── cd4_comparison-2.png │ │ ├── plot_cd3d-1.png │ │ ├── plot_cd4-1.png │ │ ├── unnamed-chunk-1-1.png │ │ ├── unnamed-chunk-2-1.png │ │ ├── unnamed-chunk-3-1.png │ │ ├── unnamed-chunk-4-1.png │ │ └── unnamed-chunk-5-1.png ├── pacmap.Rmd ├── pacmap.html ├── pacmap.md ├── pacmap_files │ ├── figure-gfm │ │ ├── explore-1.png │ │ ├── explore2-1.png │ │ └── pacmap_dim-1.png │ └── figure-html │ │ ├── explore-1.png │ │ ├── explore2-1.png │ │ └── pacmap_dim-1.png ├── presto.html ├── presto.md ├── presto.rmd ├── schex.Rmd ├── schex.html ├── schex.md ├── schex_files │ └── figure-markdown_github │ │ ├── plot-density-1.png │ │ ├── plot-gene-1.png │ │ ├── plot-meta-1-1.png │ │ ├── plot-meta-2-1.png │ │ └── plot-meta-label-1.png ├── scvelo.Rmd ├── scvelo.html ├── scvelo.md ├── scvelo_files │ ├── figure-gfm │ │ ├── adata_plot_test-1.png │ │ ├── latent_time-1.png │ │ ├── latent_time-2.png │ │ ├── matplotlib_test-1.png │ │ ├── scvelo-1.png │ │ └── scvelo-2.png │ └── figure-html │ │ ├── latent_time-1.png │ │ ├── latent_time-2.png │ │ ├── scvelo-1.png │ │ └── scvelo-2.png ├── tricycle.Rmd ├── tricycle.html ├── tricycle.md ├── tricycle_files │ └── figure-gfm │ │ ├── density-1.png │ │ ├── density-2.png │ │ ├── loess-1.png │ │ └── plotemb-1.png ├── velocity.Rmd ├── velocity.html ├── velocity.md └── velocity_files │ └── figure-markdown_github │ └── load_data-1.png ├── man ├── ALRAChooseKPlot.Rd ├── CellBrowser.Rd ├── FastMNNIntegration.Rd ├── LearnGraph.Rd ├── PlotMiQC.Rd ├── ReadAlevin.Rd ├── ReadVelocity.Rd ├── RunALRA.Rd ├── RunBanksy.Rd ├── RunCoGAPS.Rd ├── RunFastMNN.Rd ├── RunGLMPCA.Rd ├── RunMiQC.Rd ├── RunOptimizeALS.Rd ├── RunPaCMAP.Rd ├── RunPresto.Rd ├── RunPrestoAll.Rd ├── RunQuantileAlignSNF.Rd ├── RunQuantileNorm.Rd ├── RunSNF.Rd ├── RunVelocity.Rd ├── Runtricycle.Rd ├── SeuratWrappers-package.Rd ├── StopCellbrowser.Rd ├── VeloPlot.Rd ├── as.Seurat.extras.Rd ├── as.cell_data_set.Rd ├── findMatrix.Rd ├── scVIIntegration.Rd └── writeSparseTsvChunks.Rd ├── seurat-wrappers.Rproj └── test-vignettes.sh /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/.DS_Store -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^docs$ 4 | -------------------------------------------------------------------------------- /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an Issue is closed for lack of response 4 | daysUntilClose: 14 5 | # Label requiring a response 6 | responseRequiredLabel: more-information-needed 7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable 8 | closeComment: > 9 | This issue has been automatically closed because there has been no response 10 | to our request for more information from the original author. With only the 11 | information that is currently in the issue, we don't have enough information 12 | to take action. Please reach out if you have or find the answers we need so 13 | that we can investigate further. 14 | -------------------------------------------------------------------------------- /.github/workflows/test-vignettes.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | 3 | jobs: 4 | test-vignettes: 5 | name: Test any changes to vignettes 6 | runs-on: ubuntu-latest 7 | container: 8 | image: satijalab/seurat-wrappers:latest 9 | env: 10 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 11 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 12 | 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Set R repo 17 | run: echo 'options(repos = "https://cloud.r-project.org")' > ~/.Rprofile 18 | 19 | - name: Install SeuratWrappers 20 | run: devtools::install(upgrade = FALSE) 21 | shell: Rscript {0} 22 | 23 | - name: Test Vignettes 24 | run: bash test-vignettes.sh 25 | 26 | - name: Upload files 27 | uses: actions/upload-artifact@master 28 | with: 29 | name: test-build 30 | path: test-build 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | *_cache 6 | *.h5Seurat 7 | *.h5seurat 8 | *.h5ad 9 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: SeuratWrappers 2 | Title: Community-Provided Methods and Extensions for the Seurat Object 3 | Version: 0.4.0 4 | Date: 2024-11-20 5 | Authors@R: c( 6 | person(given = 'Andrew', family = 'Butler', email = 'abutler@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0003-3608-0463')), 7 | person(given = "Saket", family = "Choudhary", email = "schoudhary@nygenome.org", role = "ctb", comment = c(ORCID = "0000-0001-5202-7633")), 8 | person(given = 'David', family = 'Collins', email = 'dcollins@nygenome.org', role = 'ctb', comment = c(ORCID = '0000-0001-9243-7821')), 9 | person(given = "Yuhan", family = "Hao", email = "yhao@nygenome.org", role = "ctb", comment = c(ORCID = "0000-0002-1810-0822")), 10 | person(given = "Austin", family = "Hartman", email = "ahartman@nygenome.org", role = "ctb", comment = c(ORCID = "0000-0001-7278-1852")), 11 | person(given = 'Paul', family = 'Hoffman', email = 'nygcSatijalab@nygenome.org', role = c('aut', 'cre'), comment = c(ORCID = '0000-0002-7693-8957')), 12 | person(given = "Gesmira", family = "Molla", email = 'gmolla@nygenome.org', role = 'ctb', comment = c(ORCID = '0000-0002-8628-5056')), 13 | person(given = 'Rahul', family = 'Satija', email = 'rsatija@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0001-9448-8833')), 14 | person(given = 'Tim', family = 'Stuart', email = 'tstuart@nygenome.org', role = 'aut', comment = c(ORCID = '0000-0002-3044-0897')) 15 | ) 16 | Description: SeuratWrappers is a collection of community-provided methods and 17 | extensions for Seurat, curated by the Satija Lab at NYGC. These methods 18 | comprise functionality not presently found in Seurat, and are able to be 19 | updated much more frequently. 20 | License: GPL-3 | file LICENSE 21 | Remotes: welch-lab/liger, 22 | hms-dbmi/conos, 23 | immunogenomics/harmony, 24 | immunogenomics/presto, 25 | satijalab/seurat-data, 26 | velocyto-team/velocyto.R, 27 | SaskiaFreytag/schex@031320d, 28 | cole-trapnell-lab/monocle3, 29 | mojaveazure/seurat-disk, 30 | powellgenomicslab/Nebulosa, 31 | atakanekiz/CIPR-Package, 32 | prabhakarlab/Banksy 33 | Depends: 34 | R (>= 3.5.0) 35 | biocViews: 36 | Imports: 37 | BiocManager, 38 | cowplot, 39 | ggplot2, 40 | igraph, 41 | Matrix, 42 | methods, 43 | remotes, 44 | rsvd, 45 | Seurat (>= 5.0.0), 46 | stats, 47 | utils, 48 | rlang 49 | Collate: 50 | 'internal.R' 51 | 'alevin.R' 52 | 'alra.R' 53 | 'banksy.R' 54 | 'cellbrowser.R' 55 | 'cogaps.R' 56 | 'conos.R' 57 | 'fast_mnn.R' 58 | 'fast_mnn_v5.R' 59 | 'glmpca.R' 60 | 'liger.R' 61 | 'miqc.R' 62 | 'monocle3.R' 63 | 'pacmap.R' 64 | 'presto.R' 65 | 'scVI.R' 66 | 'tricycle.R' 67 | 'velocity.R' 68 | Encoding: UTF-8 69 | LazyData: true 70 | RoxygenNote: 7.3.2 71 | Suggests: 72 | cipr, 73 | conos, 74 | rliger (>= 0.5.0), 75 | harmony, 76 | batchelor, 77 | SeuratData, 78 | SeuratDisk, 79 | velocyto.R, 80 | schex, 81 | tximport, 82 | fishpond, 83 | monocle3, 84 | CoGAPS, 85 | glmpca, 86 | Nebulosa, 87 | presto, 88 | flexmix, 89 | tricycle, 90 | Banksy 91 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(RunALRA,Seurat) 4 | S3method(RunALRA,default) 5 | S3method(RunPaCMAP,Seurat) 6 | S3method(RunPaCMAP,default) 7 | S3method(as.Seurat,Conos) 8 | S3method(as.Seurat,cell_data_set) 9 | S3method(as.Seurat,list) 10 | S3method(as.cell_data_set,Seurat) 11 | export(ALRAChooseKPlot) 12 | export(ExportToCellbrowser) 13 | export(FastMNNIntegration) 14 | export(PlotMiQC) 15 | export(ReadAlevin) 16 | export(ReadVelocity) 17 | export(RunALRA) 18 | export(RunBanksy) 19 | export(RunCoGAPS) 20 | export(RunFastMNN) 21 | export(RunGLMPCA) 22 | export(RunMiQC) 23 | export(RunOptimizeALS) 24 | export(RunPaCMAP) 25 | export(RunPresto) 26 | export(RunPrestoAll) 27 | export(RunQuantileAlignSNF) 28 | export(RunQuantileNorm) 29 | export(RunSNF) 30 | export(RunVelocity) 31 | export(Runtricycle) 32 | export(StopCellbrowser) 33 | export(as.cell_data_set) 34 | export(scVIIntegration) 35 | importFrom(BiocManager,install) 36 | importFrom(Matrix,Matrix) 37 | importFrom(Matrix,writeMM) 38 | importFrom(R.utils,gzip) 39 | importFrom(Seurat,"DefaultAssay<-") 40 | importFrom(Seurat,"Idents<-") 41 | importFrom(Seurat,"Key<-") 42 | importFrom(Seurat,"Loadings<-") 43 | importFrom(Seurat,"Misc<-") 44 | importFrom(Seurat,"Tool<-") 45 | importFrom(Seurat,"VariableFeatures<-") 46 | importFrom(Seurat,CombinePlots) 47 | importFrom(Seurat,CreateAssayObject) 48 | importFrom(Seurat,CreateDimReducObject) 49 | importFrom(Seurat,CreateSeuratObject) 50 | importFrom(Seurat,DefaultAssay) 51 | importFrom(Seurat,Embeddings) 52 | importFrom(Seurat,FetchData) 53 | importFrom(Seurat,FindAllMarkers) 54 | importFrom(Seurat,FindMarkers) 55 | importFrom(Seurat,GetAssayData) 56 | importFrom(Seurat,Idents) 57 | importFrom(Seurat,IsGlobal) 58 | importFrom(Seurat,Loadings) 59 | importFrom(Seurat,LogSeuratCommand) 60 | importFrom(Seurat,Project) 61 | importFrom(Seurat,Reductions) 62 | importFrom(Seurat,SelectIntegrationFeatures) 63 | importFrom(Seurat,SplitObject) 64 | importFrom(Seurat,Stdev) 65 | importFrom(Seurat,Tool) 66 | importFrom(Seurat,VariableFeatures) 67 | importFrom(Seurat,as.Graph) 68 | importFrom(Seurat,as.Seurat) 69 | importFrom(Seurat,as.SingleCellExperiment) 70 | importFrom(cowplot,theme_cowplot) 71 | importFrom(data.table,data.table) 72 | importFrom(data.table,fwrite) 73 | importFrom(data.table,setDTthreads) 74 | importFrom(ggplot2,aes_string) 75 | importFrom(ggplot2,geom_line) 76 | importFrom(ggplot2,geom_point) 77 | importFrom(ggplot2,geom_vline) 78 | importFrom(ggplot2,ggplot) 79 | importFrom(ggplot2,labs) 80 | importFrom(ggplot2,scale_x_continuous) 81 | importFrom(igraph,get.adjacency) 82 | importFrom(methods,"slot<-") 83 | importFrom(methods,as) 84 | importFrom(methods,new) 85 | importFrom(methods,slot) 86 | importFrom(remotes,install_github) 87 | importFrom(reticulate,import) 88 | importFrom(reticulate,py_module_available) 89 | importFrom(rlang,"%||%") 90 | importFrom(rlang,check_installed) 91 | importFrom(rlang,duplicate) 92 | importFrom(rsvd,rsvd) 93 | importFrom(stats,as.dist) 94 | importFrom(stats,pnorm) 95 | importFrom(stats,quantile) 96 | importFrom(stats,sd) 97 | importFrom(stats,setNames) 98 | importFrom(stats,wilcox.test) 99 | importFrom(tools,file_ext) 100 | importFrom(utils,assignInNamespace) 101 | importFrom(utils,browseURL) 102 | importFrom(utils,capture.output) 103 | importFrom(utils,install.packages) 104 | importFrom(utils,menu) 105 | importFrom(utils,packageVersion) 106 | importFrom(utils,setTxtProgressBar) 107 | importFrom(utils,txtProgressBar) 108 | importFrom(utils,write.table) 109 | -------------------------------------------------------------------------------- /R/alevin.R: -------------------------------------------------------------------------------- 1 | #' @include internal.R 2 | #' 3 | NULL 4 | 5 | #' Load alevin quantification data 6 | #' 7 | #' A wrapper around tximport to create a \code{SeuratObject} 8 | #' from alevin quantification data. 9 | #' 10 | #' @param file path to \code{quants_mat.gz} file within 11 | #' alevin directory 12 | #' @param getMeta logical, option to use \code{tximeta} to 13 | #' programmatically obtain gene range information, default 14 | #' is FALSE. Ranges are stored in \code{chr}, \code{start}, 15 | #' and \code{end} in the \code{meta.features} slot. 16 | #' @param meanAndVariance logical, should mean and variance 17 | #' of counts be returned in \code{counts} and \code{data} 18 | #' slots, respectively 19 | #' @param ... extra arguments passed to \code{tximport}, 20 | #' for example, 21 | #' \code{alevinArgs=list(filterBarcodes=TRUE)}. 22 | #' 23 | #' @return returns a Seurat object with alevin counts 24 | #' @seealso \code{\link[alevin]{alevin}} 25 | #' @author Avi Srivastava 26 | #' @references Srivastava, Avi, et al. "Alevin efficiently 27 | #' estimates accurate gene abundances from dscRNA-seq data." 28 | #' Genome biology 20.1 (2019): 65. 29 | #' @export 30 | ReadAlevin <- function(file, getMeta=FALSE, meanAndVariance=FALSE, ...) { 31 | CheckPackage(package = 'tximport', repository = 'bioconductor') 32 | CheckPackage(package = 'fishpond', repository = 'bioconductor') 33 | hasTximeta <- requireNamespace("tximeta", quietly=TRUE) 34 | metaSuccess <- FALSE 35 | if (getMeta) { 36 | if (!hasTximeta) 37 | stop("tximeta is not installed, use BiocManager::install()") 38 | se <- tximeta::tximeta(file, type="alevin", ...) 39 | metaSuccess <- !is.null(SummarizedExperiment::rowRanges(se)) 40 | if (meanAndVariance & 41 | all(c("mean","variance") %in% SummarizedExperiment::assayNames(se))) { 42 | txi <- list(mean=SummarizedExperiment::assays(se)[["mean"]], 43 | variance=SummarizedExperiment::assays(se)[["variance"]]) 44 | } else { 45 | txi <- list(counts=SummarizedExperiment::assays(se)[["counts"]]) 46 | } 47 | } else { 48 | txi <- tximport::tximport(file, type="alevin", ...) 49 | } 50 | if (meanAndVariance) { 51 | if (!all(c("mean","variance") %in% names(txi))) 52 | stop("mean and variance not present in alevin directory") 53 | obj <- CreateSeuratObject(counts=txi$mean) 54 | obj <- Seurat::SetAssayData(obj, "data", txi$variance) 55 | } else { 56 | obj <- CreateSeuratObject(counts=txi$counts) 57 | } 58 | if (metaSuccess) { 59 | r <- SummarizedExperiment::rowRanges(se) 60 | obj[["RNA"]][["chr"]] <- as.character(GenomicRanges::seqnames(r)) 61 | obj[["RNA"]][["start"]] <- GenomicRanges::start(r) 62 | obj[["RNA"]][["end"]] <- GenomicRanges::end(r) 63 | } 64 | return(obj) 65 | } 66 | -------------------------------------------------------------------------------- /R/cogaps.R: -------------------------------------------------------------------------------- 1 | #' @include internal.R 2 | #' 3 | NULL 4 | 5 | #' Run CoGAPs on a Seurat object 6 | #' 7 | #' @param object Seurat object 8 | #' @param assay Assay to pull data from 9 | #' @param slot Slot to pull data from. 10 | #' @param params \code{\link[CoGAPS]{CogapsParams}} object for specifying parameter settings 11 | #' @param temp.file Name of temporary data matrix file to create if running in a distributed mode. 12 | #' Setting to TRUE will generate the file name using \code{tempfile}. 13 | #' @param reduction.name Name of the CoGAPS reduction returned 14 | #' @param reduction.key Key for the CoGAPS reduction returned 15 | #' 16 | #' @return Returns a Seurat object with the CoGAPS results stored as a \code{\link{DimReduc}} object 17 | #' @seealso \code{\link[CoGAPS]{CoGAPS}} 18 | #' @references E.J. Fertig, J. Ding, A.V. Favorov, G. Parmigiani, and M.F. Ochs (2010) CoGAPS: an 19 | #' integrated R/C++ package to identify overlapping patterns of activation of biological processes 20 | #' from expression data. Bioinformatics 26:2792-2793. 21 | #' 22 | #' @importFrom Matrix writeMM 23 | #' 24 | #' @export 25 | RunCoGAPS <- function( 26 | object, 27 | assay = NULL, 28 | slot = "counts", 29 | params = NULL, 30 | temp.file = NULL, 31 | reduction.name = "CoGAPS", 32 | reduction.key = "CoGAPS_", 33 | ... 34 | ) { 35 | SeuratWrappers:::CheckPackage(package = 'CoGAPS', repository = 'bioconductor') 36 | assay <- assay %||% DefaultAssay(object = object) 37 | dat <- GetAssayData(object = object, assay = assay, slot = slot) 38 | dat <- log2(x = dat + 1) 39 | geneNames <- rownames(x = dat) 40 | sampleNames <- colnames(x = dat) 41 | if (!is.null(temp.file)) { 42 | if (isTRUE(x = temp.file)) { 43 | temp.file <- paste0(tempfile(), ".mtx") 44 | } else if (file.exists(temp.file)) { 45 | stop("temp.file already exists and would be overwritten. Please either remove or specify a new name.") 46 | } 47 | dat <- as(object = dat, Class = "dgCMatrix") 48 | Matrix::writeMM(obj = dat, file = temp.file) 49 | dat <- temp.file 50 | } else { 51 | dat <- as.matrix(x = dat) 52 | } 53 | if (!is.null(x = params)) { 54 | CoGAPS_results <- CoGAPS::CoGAPS( 55 | data = dat, 56 | params = params, 57 | geneNames = geneNames, 58 | sampleNames = sampleNames, 59 | ... 60 | ) 61 | } else { 62 | CoGAPS_results <- CoGAPS::CoGAPS( 63 | data = dat, 64 | geneNames = geneNames, 65 | sampleNames = sampleNames, 66 | ... 67 | ) 68 | } 69 | object[["CoGAPS"]] <- CreateDimReducObject( 70 | embeddings = slot(object = CoGAPS_results, name = "sampleFactors"), 71 | loadings = slot(object = CoGAPS_results, name = "featureLoadings"), 72 | key = "CoGAPS_", 73 | assay = assay 74 | ) 75 | return(object) 76 | } 77 | -------------------------------------------------------------------------------- /R/conos.R: -------------------------------------------------------------------------------- 1 | #' Extra conversions to Seurat objects 2 | #' 3 | #' @inheritParams Seurat::as.Seurat 4 | #' 5 | #' @rdname as.Seurat.extras 6 | #' @name as.Seurat 7 | #' 8 | #' @seealso \code{\link[Seurat]{as.Seurat}} 9 | #' 10 | #' @aliases as.Seurat 11 | #' 12 | NULL 13 | 14 | #' @param method Name of matching method graph was built using 15 | #' @param reduction Name of graph embedding, if calculated 16 | #' @param idents Name of clutering method to set as identity class 17 | #' 18 | #' @details 19 | #' The \code{Conos} method for \code{\link[Seurat]{as.Seurat}} only works if all 20 | #' samples are \code{Seurat} objects. The object is initially constructed by merging 21 | #' all samples together using \code{\link[Seurat]{merge}}, any sample-level dimensional 22 | #' reductions and graphs will be lost during the merge. Extra information is added 23 | #' to the resulting Seurat object as follows: 24 | #' \itemize{ 25 | #' \item Pairwise alignments will be stored in miscellaneous data, as will any 26 | #' other miscellaneous information 27 | #' \item If a graph is present in the \code{graph} field, it will be stored as 28 | #' a \code{Graph} object, reordered to match cell order in the new \code{Seurat} 29 | #' object. It will be named "\code{DefaultAssay(SeuratObject)}_\code{method}" 30 | #' \item If an embedding is present in the \code{embedding} field as a 31 | #' \code{\link{matrix}}, it will be stored as a \code{DimReduc} object with the 32 | #' name \code{reduction} and a key value of "\code{toupper(reduction)}_" 33 | #' \item If the length of the \code{clusters} field is greater than zero, 34 | #' clustering information (\code{groups} field) will be added to object metadata. 35 | #' Extra information (\code{result} field) will be added to miscellaneous data 36 | #' with the name "conos.\code{clustering}.result" 37 | #' \item If present, the first clustering entry in the \code{clusters} field 38 | #' will be set as object identity classes 39 | #' } 40 | #' 41 | #' @importFrom igraph get.adjacency 42 | #' @importFrom utils txtProgressBar setTxtProgressBar 43 | #' @importFrom Seurat as.Seurat Misc<- DefaultAssay as.Graph 44 | #' CreateDimReducObject Idents<- 45 | #' 46 | #' @rdname as.Seurat.extras 47 | #' @export 48 | #' @method as.Seurat Conos 49 | #' 50 | as.Seurat.Conos <- function( 51 | x, 52 | method = 'mnn', 53 | reduction = 'largeVis', 54 | idents = names(x = x$clusters)[1], 55 | verbose = TRUE, 56 | ... 57 | ) { 58 | if (!all(sapply(X = x$samples, FUN = inherits, what = 'Seurat'))) { 59 | stop( 60 | "Converting a Conos object to a Seurat object requires that all samples are Seurat v3 objects", 61 | call. = FALSE 62 | ) 63 | } 64 | if (verbose) { 65 | message("Merging ", length(x = x$samples), " samples") 66 | } 67 | object <- merge(x = x$samples[[1]], x$samples[2:length(x = x$samples)]) 68 | # Add pairs 69 | if (length(x = x$pairs) > 0) { 70 | if (verbose) { 71 | message("Adding pairwise alignments to 'conos.pairs' in miscellaneous data") 72 | } 73 | Misc(object = object, slot = 'conos.pairs') <- x$pairs 74 | } 75 | # Add graph 76 | if (!is.null(x = x$graph)) { 77 | graph <- paste(DefaultAssay(object = object), method, sep = '_') 78 | message("Adding graph as '", graph, "'") 79 | object[[graph]] <- as.Graph(x = get.adjacency(graph = x$graph)[colnames(x = object), colnames(x = object)]) 80 | } 81 | # Add graph embedding 82 | if (is.matrix(x = x$embedding)) { 83 | if (verbose) { 84 | message("Adding graph embedding as ", reduction) 85 | } 86 | object[[reduction]] <- suppressWarnings(expr = CreateDimReducObject( 87 | embeddings = x$embedding, 88 | assay = DefaultAssay(object = object), 89 | key = paste0(toupper(x = reduction), '_') 90 | )) 91 | } 92 | # Add clustering information 93 | if (length(x = x$clusters) > 0) { 94 | if (verbose) { 95 | message("Adding clustering information") 96 | pb <- txtProgressBar(min = 0, max = length(x = x$clusters), style = 3, file = stderr()) 97 | } 98 | for (clustering in names(x = x$clusters)) { 99 | object[[clustering]] <- x$clusters[[clustering]]$groups 100 | clustering.misc <- paste('conos', clustering, 'result', sep = '.') 101 | Misc(object = object, slot = clustering.misc) <- x$clusters[[clustering]]$result 102 | if (clustering == idents) { 103 | Idents(object = object) <- clustering 104 | } 105 | if (verbose) { 106 | setTxtProgressBar(pb = pb, value = 1 + pb$getVal()) 107 | } 108 | } 109 | } 110 | if (verbose) { 111 | close(con = pb) 112 | } 113 | # Add miscellaneous information 114 | if (length(x = x$misc) > 0) { 115 | if (verbose) { 116 | message("Adding extra information to 'conos.misc' in miscellaneous data") 117 | } 118 | Misc(object = object, slot = 'conos.misc') <- x$misc 119 | } 120 | return(object) 121 | } 122 | -------------------------------------------------------------------------------- /R/fast_mnn.R: -------------------------------------------------------------------------------- 1 | #' @include internal.R 2 | #' 3 | NULL 4 | 5 | #' Run fastMNN 6 | #' 7 | #' @param object.list A list of Seurat objects 8 | #' @param assay Assay to use, defaults to the default assay of the first object 9 | #' @param features Either a list of features to use when calculating batch 10 | #' correction, or a number (2000 by default) of variable features to select. 11 | #' @param reduction.name Name to store resulting DimReduc object as 12 | #' @param reduction.key Key for resulting DimReduc 13 | #' @param reconstructed.assay Name for the assay containing the low-rank 14 | #' reconstruction of the expression matrix. 15 | #' @param verbose Print messages from \code{\link[Seurat]{SelectIntegrationFeatures}} 16 | #' @param ... Extra parameters passed to \code{\link[batchelor]{fastMNN}} 17 | #' 18 | #' @return A Seurat object merged from the objects in \code{object.list} and a 19 | #' new DimReduc of name \code{reduction.name} (key set to \code{reduction.key}) 20 | #' with corrected embeddings matrix as well as the rotation matrix used for the 21 | #' PCA stored in the feature loadings slot. Also returns an expression matrix 22 | #' reconstructed from the low-rank approximation in the 23 | #' \code{reconstructed.assay} assay; all other metadata info 24 | #' \code{\link[batchelor]{fastMNN}} is stored in the \code{tool} slot, 25 | #' accessible with \code{\link[Seurat]{Tool}} 26 | #' 27 | #' @importFrom Seurat DefaultAssay DefaultAssay<- SelectIntegrationFeatures VariableFeatures VariableFeatures<- 28 | #' as.SingleCellExperiment CreateDimReducObject Tool<- LogSeuratCommand 29 | #' 30 | #' @export 31 | #' 32 | #' @seealso \code{\link[batchelor]{fastMNN}} \code{\link[Seurat]{Tool}} 33 | #' 34 | RunFastMNN <- function( 35 | object.list, 36 | assay = NULL, 37 | features = 2000, 38 | reduction.name = "mnn", 39 | reduction.key = "mnn_", 40 | reconstructed.assay = "mnn.reconstructed", 41 | verbose = TRUE, 42 | ... 43 | ) { 44 | CheckPackage(package = "batchelor", repository = "bioconductor") 45 | if (!all(sapply(X = object.list, FUN = inherits, what = "Seurat"))) { 46 | stop("'object.list' must be a list of Seurat objects", 47 | call. = FALSE) 48 | } 49 | if (length(x = object.list) < 2) { 50 | stop("'object.list' must contain multiple Seurat objects for integration", 51 | call. = FALSE) 52 | } 53 | assay <- assay %||% DefaultAssay(object = object.list[[1]]) 54 | for (i in 1:length(x = object.list)) { 55 | DefaultAssay(object = object.list[[i]]) <- assay 56 | } 57 | if (is.numeric(x = features)) { 58 | if (verbose) { 59 | message(paste("Computing", features, "integration features")) 60 | } 61 | features <- SelectIntegrationFeatures( 62 | object.list = object.list, 63 | nfeatures = features, 64 | assay = rep(assay, length(x = object.list)) 65 | ) 66 | } 67 | objects.sce <- lapply( 68 | X = object.list, 69 | FUN = function(x, f) { 70 | return(as.SingleCellExperiment(x = subset(x = x, features = f))) 71 | }, 72 | f = features 73 | ) 74 | integrated <- merge( 75 | x = object.list[[1]], 76 | y = object.list[2:length(x = object.list)] 77 | ) 78 | out <- do.call( 79 | what = batchelor::fastMNN, 80 | args = c( 81 | objects.sce, 82 | list(...) 83 | ) 84 | ) 85 | rownames(x = SingleCellExperiment::reducedDim(x = out)) <- colnames(x = integrated) 86 | colnames(x = SingleCellExperiment::reducedDim(x = out)) <- paste0(reduction.key, 1:ncol(x = SingleCellExperiment::reducedDim(x = out))) 87 | integrated[[reduction.name]] <- CreateDimReducObject( 88 | embeddings = SingleCellExperiment::reducedDim(x = out), 89 | loadings = as.matrix(SingleCellExperiment::rowData(x = out)), 90 | assay = DefaultAssay(object = integrated), 91 | key = reduction.key 92 | ) 93 | # Add reconstructed matrix (gene x cell) 94 | integrated[[reconstructed.assay]] <- CreateAssayObject( 95 | data = as(object = SummarizedExperiment::assay(x = out), Class = "sparseMatrix"), 96 | ) 97 | # Add variable features 98 | VariableFeatures(object = integrated[[reconstructed.assay]]) <- features 99 | Tool(object = integrated) <- S4Vectors::metadata(x = out) 100 | integrated <- LogSeuratCommand(object = integrated) 101 | return(integrated) 102 | } 103 | 104 | -------------------------------------------------------------------------------- /R/fast_mnn_v5.R: -------------------------------------------------------------------------------- 1 | #' @include internal.R 2 | #' 3 | NULL 4 | 5 | #' Run fastMNN in Seurat 5 6 | #' 7 | #' @param object A merged seurat object 8 | #' @param groups A one-column data frame with grouping information 9 | #' @param layers Layers to use 10 | #' @param assay Assay to use, defaults to the default assay of the first object 11 | #' @param features Either a list of features to use when calculating batch 12 | #' correction, or a number (2000 by default) of variable features to select. 13 | #' @param reduction.name Name to store resulting DimReduc object as 14 | #' @param reduction.key Key for resulting DimReduc 15 | #' @param reconstructed.assay Name for the assay containing the low-rank 16 | #' reconstruction of the expression matrix. 17 | #' @param verbose Print messages 18 | #' @param ... Extra parameters passed to \code{\link[batchelor]{fastMNN}} 19 | #' 20 | #' @return A Seurat object merged from the objects in \code{object.list} and a 21 | #' new DimReduc of name \code{reduction.name} (key set to \code{reduction.key}) 22 | #' with corrected embeddings matrix as well as the rotation matrix used for the 23 | #' PCA stored in the feature loadings slot. Also returns an expression matrix 24 | #' reconstructed from the low-rank approximation in the 25 | #' \code{reconstructed.assay} assay; all other metadata info 26 | #' \code{\link[batchelor]{fastMNN}} is stored in the \code{tool} slot, 27 | #' accessible with \code{\link[Seurat]{Tool}} 28 | #' 29 | #' @importFrom Seurat DefaultAssay DefaultAssay<- SelectIntegrationFeatures VariableFeatures VariableFeatures<- 30 | #' as.SingleCellExperiment CreateDimReducObject Tool<- LogSeuratCommand 31 | #' @importFrom rlang check_installed 32 | #' 33 | #' @export 34 | #'@note This function requires the 35 | #' \href{https://rdrr.io/github/LTLA/batchelor/}{\pkg{batchelor}} package 36 | #' to be installed 37 | #' 38 | #' @examples 39 | #' \dontrun{ 40 | #' # Preprocessing 41 | #' obj <- SeuratData::LoadData("pbmcsca") 42 | #' obj[["RNA"]] <- split(obj[["RNA"]], f = obj$Method) 43 | #' obj <- NormalizeData(obj) 44 | #' obj <- FindVariableFeatures(obj) 45 | #' obj <- ScaleData(obj) 46 | #' obj <- RunPCA(obj) 47 | #' 48 | #' # After preprocessing, we integrate layers: 49 | #' obj <- IntegrateLayers(object = obj, method = FastMNNIntegration, 50 | #' new.reduction = 'integrated.mnn', verbose = FALSE) 51 | #' 52 | #' # We can also add parameters specific to FastMNN. 53 | #' # Here we set `k` to specify the number of nearest neighbors to use when identifying MNNs: 54 | #' obj <- IntegrateLayers(object = obj, method = FastMNNIntegration, 55 | #' new.reduction = 'integrated.mnn', k = 15, verbose = FALSE) 56 | #' } 57 | #' 58 | #' @seealso \code{\link[batchelor]{fastMNN}} \code{\link[Seurat]{Tool}} 59 | #' 60 | FastMNNIntegration <- function( 61 | object, 62 | assay = NULL, 63 | orig = NULL, 64 | groups = NULL, 65 | layers = NULL, 66 | scale.layer = NULL, 67 | features = 2000, 68 | new.reduction = "integrated.mnn", 69 | reduction.key = "mnn_", 70 | reconstructed.assay = "mnn.reconstructed", 71 | verbose = TRUE, 72 | ... 73 | ) { 74 | check_installed( 75 | pkg = "batchelor", 76 | reason = "for running integration with mnnCorrect" 77 | ) 78 | object <- CreateSeuratObject(object) 79 | if (is.numeric(x = features)) { 80 | if (verbose) { 81 | message(paste("Computing", features, "integration features")) 82 | } 83 | features <- SelectIntegrationFeatures5(object = object, features = features) 84 | } 85 | layers <- layers %||% Layers(object, search = 'data') 86 | if (verbose) { 87 | message("Converting layers to SingleCellExperiment") 88 | } 89 | objects.sce <- lapply( 90 | X = layers, 91 | FUN = function(x, f) { 92 | return(as.SingleCellExperiment( 93 | x = subset(x = object, 94 | features = f, 95 | cells = colnames(LayerData(object, layer = x))) 96 | ) 97 | ) 98 | }, 99 | f = features 100 | ) 101 | if (verbose) { 102 | message("Running fastMNN") 103 | } 104 | out <- do.call( 105 | what = batchelor::fastMNN, 106 | args = c( 107 | objects.sce, 108 | list(...) 109 | ) 110 | ) 111 | colnames(x = SingleCellExperiment::reducedDim(x = out)) <- paste0(reduction.key, 1:ncol(x = SingleCellExperiment::reducedDim(x = out))) 112 | reduction <- CreateDimReducObject( 113 | embeddings = SingleCellExperiment::reducedDim(x = out), 114 | loadings = as.matrix(SingleCellExperiment::rowData(x = out)), 115 | assay = DefaultAssay(object = object), 116 | key = reduction.key 117 | ) 118 | # Add reconstructed matrix (gene x cell) 119 | reconstructed_assay <- CreateAssayObject( 120 | data = as(object = SummarizedExperiment::assay(x = out), Class = "sparseMatrix"), 121 | ) 122 | # Add variable features 123 | VariableFeatures(object = reconstructed_assay) <- features 124 | #Tool(object = object) <- S4Vectors::metadata(x = out) 125 | #object <- LogSeuratCommand(object = object) 126 | output.list <- list(reduction, reconstructed_assay) 127 | names(output.list) <- c(new.reduction, reconstructed.assay) 128 | return(output.list) 129 | } 130 | 131 | attr(x = FastMNNIntegration, which = 'Seurat.method') <- 'integration' 132 | -------------------------------------------------------------------------------- /R/glmpca.R: -------------------------------------------------------------------------------- 1 | #' @include internal.R 2 | #' 3 | NULL 4 | 5 | #' Run GLMPCA 6 | #' 7 | #' @param object A Seurat object 8 | #' @param L The number of dimensions to return (defaults to 5) 9 | #' @param assay Assay to use, defaults to the default assay 10 | #' @param features A list of features to use when performing GLM-PCA. If null, defaults to variable features. 11 | #' @param reduction.name Name to store resulting DimReduc object as. Defaults to glmpca 12 | #' @param reduction.key Key for resulting DimReduc. Defaults to GLMPC_ 13 | #' @param ... Extra parameters passed to \code{\link[glmpca]{glmpca}} 14 | #' 15 | #' @return A Seurat object containing the output of GLMPCA stored as a DimReduc object. 16 | #' @importFrom Seurat DefaultAssay DefaultAssay<- CreateDimReducObject Tool<- LogSeuratCommand 17 | #' 18 | #' @author Will Townes 19 | #' @references Townes, W., Hicks, SC, Aryee, MJ, Irizarry, RA. (2019). "Feature selection and dimension reduction for single-cell RNA-Seq based on a multinomial model." 20 | #' Genome Biology. 21 | #' 22 | #' @examples 23 | #' \dontrun{ 24 | #' pbmc_small 25 | #' pbmc_small <- RunGLMPCA(pbmc_small) 26 | #' DimPlot(pbmc_small, redunction = 'glmpca') 27 | #' } 28 | #' 29 | #' @export 30 | #' 31 | RunGLMPCA <- function( 32 | object, 33 | L = 5, 34 | assay = NULL, 35 | features = NULL, 36 | reduction.name = 'glmpca', 37 | reduction.key = 'GLMPC_', 38 | verbose = TRUE, 39 | ... 40 | ) { 41 | CheckPackage(package = 'glmpca', repository = 'CRAN') 42 | if (!inherits(x = object,what = 'Seurat')) { 43 | stop("'object' must be a Seurat object", call. = FALSE) 44 | } 45 | assay <- assay %||% DefaultAssay(object = object) 46 | DefaultAssay(object = object) <- assay 47 | features <- features %||% VariableFeatures(object) 48 | data <- GetAssayData(object = object, slot = 'counts') 49 | features <- intersect(x = features, y = rownames(x = data)) 50 | if (length(x = features) == 0) { 51 | stop("Please specify a subset of features for GLM-PCA") 52 | } 53 | data <- data[features, ] 54 | glmpca_results <- glmpca:::glmpca(Y = data, L = L, ...) 55 | glmpca_dimnames <- paste0(reduction.key, 1:L) 56 | factors<-as.matrix(glmpca_results$factors) 57 | loadings<-as.matrix(glmpca_results$loadings) 58 | colnames(x = factors) <- glmpca_dimnames 59 | colnames(x = loadings) <- glmpca_dimnames 60 | factors_l2_norm <- sqrt(colSums(factors^2)) 61 | #strip S3 class "glmpca" to enable it to pass validObject() 62 | class(glmpca_results)<-NULL 63 | #save memory by removing factors and loadings since they are stored separately 64 | glmpca_results$factors<-glmpca_results$loadings<-NULL 65 | object[[reduction.name]] <- CreateDimReducObject( 66 | embeddings = factors, 67 | key = reduction.key, 68 | loadings = loadings, 69 | stdev = factors_l2_norm, 70 | assay = assay, 71 | global = TRUE, 72 | misc = glmpca_results 73 | ) 74 | object <- LogSeuratCommand(object = object) 75 | return(object) 76 | } 77 | -------------------------------------------------------------------------------- /R/tricycle.R: -------------------------------------------------------------------------------- 1 | #' @include internal.R 2 | #' 3 | NULL 4 | 5 | #' Run estimate_cycle_position on a Seurat object 6 | #' 7 | #' This function run estimate_cycle_position function on Seurat object. It uses 8 | #' the tricycle internal reference projection matrix. 9 | #' 10 | #' @param object Seurat object 11 | #' @param assay Assay to use, defaults to the default assay 12 | #' @param slot Slot to use. It should be library size adjusted **log-expression** values. 13 | #' Note that it is convention that we rename "logcounts" to "data" when converting SingleCellExperiment to Seurat object. 14 | #' See also \code{\link[Seurat]{as.Seurat}}. Defaults to "data" 15 | #' @param reduction.name Name of the cell cycle projection returned 16 | #' @param reduction.key Key for the cell cycle projection returned 17 | #' @param gname Alternative rownames of \code{object}. If provided, this will be used to map genes within \code{object} with genes in reference. 18 | #' If not provided, the rownames of \code{object} will be used instead. Default: NULL 19 | #' @param gname.type The type of gene names as in \code{gname} or rownames of \code{object}. It can be either 'ENSEMBL' or 'SYMBOL'. Default: 'ENSEMBL' 20 | #' @param species The type of species in \code{object}. It can be either 'mouse' or 'human'. Default: 'mouse' 21 | #' @param AnnotationDb An AnnotationDb objects. If the user provides rownames in the format of Ensembl IDs and project human data, 22 | #' this object will be used to map Ensembl IDs to gene SYMBOLs. If no AnnotationDb object being given, the function will use \code{\link[org.Hs.eg.db]{org.Hs.eg.db}}. 23 | #' @param center.pc1 The center of PC1 when defining the angle. Default: 0 24 | #' @param center.pc2 The center of PC2 when defining the angle. Default: 0 25 | #' 26 | #' @export 27 | Runtricycle <- function( 28 | object, 29 | assay = NULL, 30 | slot = "data", 31 | reduction.name = "tricycleEmbedding", 32 | reduction.key = "tricycleEmbedding_", 33 | gname = NULL, 34 | gname.type = c("ENSEMBL", "SYMBOL"), 35 | species = c("mouse", "human"), 36 | AnnotationDb = NULL, 37 | center.pc1 = 0, 38 | center.pc2 = 0) { 39 | SeuratWrappers:::CheckPackage(package = 'tricycle', repository = 'bioconductor') 40 | assay <- assay %||% DefaultAssay(object = object) 41 | data.m <- GetAssayData(object = object, assay = assay, slot = slot) 42 | 43 | projection.m <- tricycle:::.project_cycle_space(data.m, ref.m = NULL, gname = gname, gname.type = gname.type, species = species, AnnotationDb = AnnotationDb) 44 | object$tricyclePosition <- tricycle:::.getTheta(projection.m, center.pc1 = center.pc1, center.pc2 = center.pc2) 45 | 46 | object[[reduction.name]] <- CreateDimReducObject( 47 | embeddings = projection.m, 48 | key = reduction.key, 49 | assay = assay 50 | ) 51 | return(object) 52 | 53 | } 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SeuratWrappers 2 | 3 | SeuratWrappers is a collection of community-provided methods and extensions for [Seurat](https://satijalab.org/seurat/), curated by the Satija Lab at NYGC. These methods comprise functionality not presently found in Seurat, and are able to be updated much more frequently. 4 | 5 | Please see our [contribution guide](https://github.com/satijalab/seurat.wrappers/wiki) for assistance and guidelines in developing and adding new methods to SeuratWrappers 6 | 7 | Individual method vignettes can be found in the [`docs/`](https://github.com/satijalab/seurat.wrappers/tree/master/docs) directory, we recommend looking at the standard markdown (`*.md`) files when viewing on GitHub 8 | 9 | Installation can be accomplished through [remotes](https://cran.r-project.org/package=remotes) 10 | 11 | ```R 12 | remotes::install_github('satijalab/seurat-wrappers') 13 | ``` 14 | 15 | ## Method Listing 16 | 17 | | Package | Vignette | Reference | Source | 18 | | ------- | -------- | --------- | ------ | 19 | | Monocle 3 | [Calculating Trajectories with Monocle 3 and Seurat](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/monocle3.html) | Cao et al, Nature 2019 | https://cole-trapnell-lab.github.io/monocle3 | 20 | | scVelo | [Estimating RNA Velocity using Seurat and scVelo](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/scvelo.html) | Bergen et al, bioRxiv 2019 | https://scvelo.readthedocs.io | 21 | | CoGAPS | [Running CoGAPS on Seurat Objects](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/cogaps.html) | Stein-O’Brien et al, Cell Systems 2019 | https://www.bioconductor.org/packages/release/bioc/html/CoGAPS.html | 22 | | glmpca | [Running GLM-PCA on a Seurat Object](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/glmpca.html) | Townes et al, Genome Biology 2019 | https://github.com/willtownes/glmpca | 23 | | Conos | [Integration of datasets using Conos](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/conos.html) | Barkas et al, Nature Methods 2019 | https://github.com/hms-dbmi/conos | 24 | | LIGER | [Integrating Seurat objects using LIGER](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/liger.html) | Welch et al, Cell 2019 | https://github.com/MacoskoLab/liger | 25 | | fastMNN | [Running fastMNN on Seurat Objects](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/fast_mnn.html) | Nature Biotechnology 2018 | https://bioconductor.org/packages/release/bioc/html/batchelor.html | 26 | | Harmony | [Integration of datasets using Harmony](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/harmony.html) | Korsunsky et al, bioRxiv 2018 | https://github.com/immunogenomics/harmony | 27 | | ALRA | [Zero-preserving imputation with ALRA](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/alra.html) | Linderman et al, bioRxiv 2018 | https://github.com/KlugerLab/ALRA | 28 | | Velocity | [Estimating RNA Velocity using Seurat](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/velocity.html) | La Manno et al, Nature 2018 | https://velocyto.org | 29 | | schex | [Using schex with Seurat](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/schex.html) | Freytag, R package 2019 | https://github.com/SaskiaFreytag/schex | 30 | | alevin | [Import alevin counts into Seurat](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/alevin.html) | Srivastava et. al., Genome Biology 2019 | https://github.com/k3yavi/alevin-Rtools | 31 | | Nebulosa | [Visualization of gene expression with Nebulosa](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/nebulosa.html) | Jose Alquicira-Hernandez and Joseph E. Powell, _Under Review_ | https://github.com/powellgenomicslab/Nebulosa | 32 | | CIPR | [Using CIPR with human PBMC data](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/cipr.html) | Ekiz et. al., BMC Bioinformatics 2020 | https://github.com/atakanekiz/CIPR-Package | 33 | | miQC | [Running miQC on Seurat objects](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/miQC.html) | Hippen et. al., bioRxiv 2021 | https://github.com/greenelab/miQC | 34 | | tricycle | [Running estimate_cycle_position from tricycle on Seurat Objects](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/tricycle.html) | Zheng et. al., bioRxiv 2021 | https://www.bioconductor.org/packages/release/bioc/html/tricycle.html | 35 | | PaCMAP | [Running PaCMAP on Seurat Objects](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/pacmap.html) | Wang et. al, JMLR 2021; Huang et. al, Communications Biology 2022 | https://github.com/YingfanWang/PaCMAP | 36 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # SeuratWrappers Vignettes 2 | 3 | This directory contains individual method vignettes for each method provided by SeuratWrappers. Generally speaking, each vignette will have three files. Each file has the same content, just formatted and rendered differently: 4 | - `*.Rmd`: these are the source Rmarkdown files used to generate the other files. Viewing them will show only the raw code 5 | - `*.html`: these are knitted HTML files. Viewing them on GitHub will show only the raw HTML code. To view rendered HTML, checkout our [vignettes](https://satijalab.org/seurat/vignettes.html) page or use the wonderful [GitHub HTML Preview service](https://htmlpreview.github.io/); links to rendered HTMLs are also provided below 6 | - `*.md`: these are knited Markdown files. Viewing them will show the rendered Markdown content, useful for browsing here on GitHub 7 | 8 | ## Method Listing 9 | 10 | | Package | Vignette | Reference | Source | 11 | | ------- | -------- | --------- | ------ | 12 | | Conos | [Integration of datasets using Conos](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/conos.html) | Barkas et al, Nature Methods 2019 | https://github.com/hms-dbmi/conos | 13 | | LIGER | [Integrating Seurat objects using LIGER](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/liger.html) | Welch et al, Cell 2019 | https://github.com/MacoskoLab/liger | 14 | | fastMNN | [Running fastMNN on Seurat Objects](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/fast_mnn.html) | Nature Biotechnology 2018 | https://bioconductor.org/packages/release/bioc/html/scran.html | 15 | | Harmony | [Integration of datasets using Harmony](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/harmony.html) | Korsunsky et al, bioRxiv 2018 | https://github.com/immunogenomics/harmony | 16 | | ALRA | [Zero-preserving imputation with ALRA](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/alra.html) | Linderman et al, bioRxiv 2018 | https://github.com/KlugerLab/ALRA | 17 | | Velocity | [Estimating RNA Velocity using Seurat](http://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/velocity.html) | La Manno et al, Nature 2018 | https://velocyto.org | 18 | -------------------------------------------------------------------------------- /docs/alevin.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Import alevin counts & generate Seurat object" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: true 7 | toc: true 8 | toc_depth: 3 9 | fig_width: 16 10 | html_document: 11 | df_print: kable 12 | theme: united 13 | fig_height: 5 14 | fig_width: 16 15 | out_height: 4 16 | --- 17 | 18 | This vignette demonstrates the import of alevin quantified counts into Seurat. Commands and parameters are based off of the [alevin tutorial](https://combine-lab.github.io/alevin-tutorial/2018/running-alevin/). If you use alevin in your work, please cite: 19 | 20 | > *Alevin efficiently estimates accurate gene abundances from dscRNA-seq data* 21 | > 22 | > Avi Srivastava, Laraib Malik, Tom Smith, Ian Sudbery & Rob Patro 23 | > 24 | > Genome Biology, 2019. 25 | > 26 | > doi: [10.1186/s13059-019-1670-y](https://doi.org/10.1186/s13059-019-1670-y) 27 | > 28 | > GitHub: https://github.com/COMBINE-lab/salmon 29 | 30 | 31 | ```{r setup, include=FALSE} 32 | knitr::opts_chunk$set( 33 | tidy = TRUE, 34 | tidy.opts = list(width.cutoff = 95), 35 | message = FALSE, 36 | warning = FALSE 37 | ) 38 | ``` 39 | 40 | Prerequisites to install: 41 | 42 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 43 | * [tximport](https://bioconductor.org/packages/tximport) 44 | 45 | ```{r packages, eval=FALSE} 46 | library(SeuratWrappers) 47 | library(tximport) 48 | ``` 49 | 50 | ## {.tabset .tabset-pills} 51 | 52 | ### Import alevin quantified counts 53 | 54 | ```{r pbmcsca, eval = FALSE, cache=TRUE} 55 | pbmc <- ReadAlevin("~/alevin_out/alevin/quants_mat.gz") 56 | ``` 57 | -------------------------------------------------------------------------------- /docs/alevin.md: -------------------------------------------------------------------------------- 1 | Import alevin counts & generate Seurat object 2 | ================ 3 | Compiled: May 18, 2020 4 | 5 | This vignette demonstrates the import of alevin quantified counts into 6 | Seurat. Commands and parameters are based off of the [alevin 7 | tutorial](https://combine-lab.github.io/alevin-tutorial/2018/running-alevin/). 8 | If you use alevin in your work, please cite: 9 | 10 | > *Alevin efficiently estimates accurate gene abundances from dscRNA-seq 11 | > data* 12 | > 13 | > Avi Srivastava, Laraib Malik, Tom Smith, Ian Sudbery & Rob Patro 14 | > 15 | > Genome Biology, 2019. 16 | > 17 | > doi: 18 | > [10.1186/s13059-019-1670-y](https://doi.org/10.1186/s13059-019-1670-y) 19 | > 20 | > GitHub: 21 | 22 | Prerequisites to install: 23 | 24 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 25 | - [tximport](https://bioconductor.org/packages/tximport) 26 | 27 | 28 | 29 | ``` r 30 | library(SeuratWrappers) 31 | library(tximport) 32 | ``` 33 | 34 | ## 35 | 36 | ### Import alevin quantified counts 37 | 38 | ``` r 39 | pbmc <- ReadAlevin("~/alevin_out/alevin/quants_mat.gz") 40 | ``` 41 | -------------------------------------------------------------------------------- /docs/alra.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Zero-preserving imputation with ALRA" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: false 7 | toc: false 8 | html_document: 9 | df_print: kable 10 | theme: united 11 | --- 12 | 13 | This vigettte demonstrates how to run ALRA on Seurat objects, which aims to recover missing values in scRNA-seq data through imputation. If you use ALRA, please cite: 14 | 15 | > *Zero-preserving imputation of scRNA-seq data using low-rank approximation* 16 | > 17 | > George C. Linderman, Jun Zhao, Yuval Kluger 18 | > 19 | > biorxiv, 2018. 20 | > 21 | > doi: https://doi.org/10.1101/397588 22 | > 23 | > GitHub: https://github.com/KlugerLab/ALRA 24 | 25 | 26 | ```{r setup, include=FALSE} 27 | knitr::opts_chunk$set( 28 | tidy = TRUE, 29 | tidy.opts = list(width.cutoff = 95), 30 | message = FALSE, 31 | warning = FALSE, 32 | fig.height = 20, 33 | fig.width = 16 34 | ) 35 | ``` 36 | 37 | Prerequisites to install: 38 | 39 | * [Seurat](https://satijalab.org/seurat/install) 40 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 41 | * [SeuratData](https://github.com/satijalab/seurat-data) 42 | 43 | ```{r packages} 44 | library(Seurat) 45 | library(SeuratData) 46 | library(SeuratWrappers) 47 | library(dplyr) 48 | ``` 49 | 50 | ### scRNA-seq imputation on pbmc3k 51 | 52 | To learn more about this dataset, type `?pbmc3k` 53 | 54 | ```{r sctransform, results='hide', cache=TRUE} 55 | InstallData("pbmc3k") 56 | data("pbmc3k") 57 | # Initial processing and visualization 58 | pbmc3k <- SCTransform(pbmc3k) %>% RunPCA() %>% RunUMAP(dims = 1:30) 59 | # run ALRA, creates alra assay of imputed values 60 | pbmc3k <- RunALRA(pbmc3k) 61 | ``` 62 | 63 | 64 | 65 | ```{r explore, results='hide', cache=TRUE} 66 | # visualize original and imputed values 67 | pbmc3k <- NormalizeData(pbmc3k, assay = 'RNA') 68 | features.plot <- c('CD3D', 'MS4A1', 'CD8A', 'GZMK', 'NCAM1', 'FCGR3A') 69 | DefaultAssay(pbmc3k) <- 'RNA' 70 | plot1 <- FeaturePlot(pbmc3k, features.plot, ncol = 2) 71 | DefaultAssay(pbmc3k) <- 'alra' 72 | plot2 <- FeaturePlot(pbmc3k, features.plot, ncol = 2, cols = c('lightgrey','red')) 73 | CombinePlots(list(plot1, plot2), ncol = 1) 74 | ``` 75 | -------------------------------------------------------------------------------- /docs/alra.md: -------------------------------------------------------------------------------- 1 | Zero-preserving imputation with ALRA 2 | ================ 3 | Compiled: August 16, 2019 4 | 5 | This vigettte demonstrates how to run ALRA on Seurat objects, which aims to recover missing values in scRNA-seq data through imputation. If you use ALRA, please cite: 6 | 7 | > *Zero-preserving imputation of scRNA-seq data using low-rank approximation* 8 | > 9 | > George C. Linderman, Jun Zhao, Yuval Kluger 10 | > 11 | > biorxiv, 2018. 12 | > 13 | > doi: 14 | > 15 | > GitHub: 16 | 17 | Prerequisites to install: 18 | 19 | - [Seurat](https://satijalab.org/seurat/install) 20 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 21 | - [SeuratData](https://github.com/satijalab/seurat-data) 22 | 23 | ``` r 24 | library(Seurat) 25 | library(SeuratData) 26 | library(SeuratWrappers) 27 | library(dplyr) 28 | ``` 29 | 30 | ### scRNA-seq imputation on pbmc3k 31 | 32 | To learn more about this dataset, type `?pbmc3k` 33 | 34 | ``` r 35 | InstallData("pbmc3k") 36 | data("pbmc3k") 37 | # Initial processing and visualization 38 | pbmc3k <- SCTransform(pbmc3k) %>% RunPCA() %>% RunUMAP(dims = 1:30) 39 | # run ALRA, creates alra assay of imputed values 40 | pbmc3k <- RunALRA(pbmc3k) 41 | ``` 42 | 43 | 44 | ``` r 45 | # visualize original and imputed values 46 | pbmc3k <- NormalizeData(pbmc3k, assay = "RNA") 47 | features.plot <- c("CD3D", "MS4A1", "CD8A", "GZMK", "NCAM1", "FCGR3A") 48 | DefaultAssay(pbmc3k) <- "RNA" 49 | plot1 <- FeaturePlot(pbmc3k, features.plot, ncol = 2) 50 | DefaultAssay(pbmc3k) <- "alra" 51 | plot2 <- FeaturePlot(pbmc3k, features.plot, ncol = 2, cols = c("lightgrey", "red")) 52 | CombinePlots(list(plot1, plot2), ncol = 1) 53 | ``` 54 | 55 | ![](alra_files/figure-markdown_github/explore-1.png) 56 | -------------------------------------------------------------------------------- /docs/alra_files/figure-markdown_github/explore-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/alra_files/figure-markdown_github/explore-1.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/hippo_gene-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/hippo_gene-1.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/hippo_viz-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/hippo_viz-1.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/hippo_viz-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/hippo_viz-2.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/multi-spatial-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/multi-spatial-1.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/multi-spatial-staggered-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/multi-spatial-staggered-1.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/multi-umap-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/multi-umap-1.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/ss_markers-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/ss_markers-1.png -------------------------------------------------------------------------------- /docs/banksy_files/figure-gfm/ss_viz-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/banksy_files/figure-gfm/ss_viz-1.png -------------------------------------------------------------------------------- /docs/cellbrowser.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Data Exploration with the UCSC Cell Browser" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: false 7 | toc: false 8 | html_document: 9 | df_print: kable 10 | theme: united 11 | --- 12 | 13 | This vignette demonstrates how to run launch a UCSC Cell Browser instance populated with data from a Seurat object. If you use cell browser, please cite: 14 | 15 | > *UCSC Single Cell Browser* 16 | > 17 | > Maximilian Haeussler, Nikolay Markov, Brian Raney, and Lucas Seninge 18 | 19 | > Documentation: https://cellbrowser.readthedocs.io 20 | 21 | ```{r setup, include=FALSE} 22 | knitr::opts_chunk$set( 23 | tidy = TRUE, 24 | tidy.opts = list(width.cutoff = 95), 25 | message = FALSE, 26 | warning = FALSE, 27 | fig.height = 20, 28 | fig.width = 16 29 | ) 30 | ``` 31 | 32 | Prerequisites to install: 33 | 34 | * [Seurat](https://satijalab.org/seurat/install) 35 | * [UCSC Cell Browser](https://pypi.org/project/cellbrowser/) 36 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 37 | * [SeuratData](https://github.com/satijalab/seurat-data) 38 | 39 | ```{r packages} 40 | library(Seurat) 41 | library(SeuratData) 42 | library(SeuratWrappers) 43 | ``` 44 | 45 | ### Viewing pbmc3k in a cell browser 46 | 47 | ```{r cellbrowser, eval=FALSE} 48 | InstallData("pbmc3k") 49 | pbmc3k <- LoadData("pbmc3k", type = "pbmc3k.final") 50 | ExportToCellbrowser(pbmc3k, dir = "out", cb.dir = "cb_out", port = 8080, reductions = "umap") 51 | ``` 52 | 53 | ![](cellbrowser.png) 54 | 55 | ```{r stopcellbrowser, eval=FALSE} 56 | # Remember to stop your cell browser instance when done 57 | StopCellbrowser() 58 | ``` 59 | -------------------------------------------------------------------------------- /docs/cellbrowser.md: -------------------------------------------------------------------------------- 1 | Data Exploration with the UCSC Cell Browser 2 | ================ 3 | Compiled: August 31, 2020 4 | 5 | This vignette demonstrates how to run launch a UCSC Cell Browser 6 | instance populated with data from a Seurat object. If you use cell 7 | browser, please cite: 8 | 9 | > *UCSC Single Cell Browser* 10 | > 11 | > Maximilian Haeussler, Nikolay Markov, Brian Raney, and Lucas Seninge 12 | 13 | > Documentation: 14 | 15 | Prerequisites to install: 16 | 17 | - [Seurat](https://satijalab.org/seurat/install) 18 | - [UCSC Cell Browser](https://pypi.org/project/cellbrowser/) 19 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 20 | - [SeuratData](https://github.com/satijalab/seurat-data) 21 | 22 | 23 | 24 | ``` r 25 | library(Seurat) 26 | library(SeuratData) 27 | library(SeuratWrappers) 28 | ``` 29 | 30 | ### Viewing pbmc3k in a cell browser 31 | 32 | ``` r 33 | InstallData("pbmc3k") 34 | pbmc3k <- LoadData("pbmc3k", type = "pbmc3k.final") 35 | ExportToCellbrowser(pbmc3k, dir = "out", cb.dir = "cb_out", port = 8080, reductions = "umap") 36 | ``` 37 | 38 | ![](cellbrowser.png) 39 | 40 | ``` r 41 | # Remember to stop your cell browser instance when done 42 | StopCellbrowser() 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/cellbrowser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cellbrowser.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-20-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-20-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-21-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-21-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-22-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-22-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-23-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-23-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-25-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-25-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-26-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-26-1.png -------------------------------------------------------------------------------- /docs/cipr_files/figure-gfm/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cipr_files/figure-gfm/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/tenPatternsBVlnPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/tenPatternsBVlnPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/tenPatternsDcVlnPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/tenPatternsDcVlnPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/tenPatternsFcgr3aVlnPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/tenPatternsFcgr3aVlnPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/tenPatternsScatterPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/tenPatternsScatterPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/tenPatternsScatterPlot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/tenPatternsScatterPlot-2.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/tenPatternsScatterPlot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/tenPatternsScatterPlot-3.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/threePatternsExampleLympVlnPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/threePatternsExampleLympVlnPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/threePatternsExampleMyeVlnPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/threePatternsExampleMyeVlnPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/threePatternsExampleScatterPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/threePatternsExampleScatterPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/threePatternsLymphoidVlnPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/threePatternsLymphoidVlnPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/threePatternsMyeloidVlnPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/threePatternsMyeloidVlnPlot-1.png -------------------------------------------------------------------------------- /docs/cogaps_files/figure-markdown_github/threePatternsScatterPlot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/cogaps_files/figure-markdown_github/threePatternsScatterPlot-1.png -------------------------------------------------------------------------------- /docs/conos.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Integration of datasets using Conos" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: true 7 | toc: true 8 | toc_depth: 3 9 | fig_width: 16 10 | html_document: 11 | df_print: kable 12 | theme: united 13 | fig_height: 5 14 | fig_width: 16 15 | out_height: 4 16 | --- 17 | 18 | This vignette demonstrates the use of the Conos package in Seurat. Commands and parameters are based off of the [Conos tutorial](https://github.com/hms-dbmi/conos/blob/master/vignettes/walkthrough.md). If you use Conos in your work, please cite: 19 | 20 | > *Joint analysis of heterogeneous single-cell RNA-seq dataset collections* 21 | > 22 | > Nikolas Barkas, Viktor Petukhov, Daria Nikolaeva, Yaroslav Lozinsky, Samuel Demharter, Konstantin Khodosevich, Peter V. Kharchenko 23 | > 24 | > Nature Methods, 2019. 25 | > 26 | > doi: [10.1038/s41592-019-0466-z](https://doi.org/10.1038/s41592-019-0466-z) 27 | > 28 | > GitHub: https://github.com/hms-dbmi/conos 29 | 30 | 31 | ```{r setup, include=FALSE} 32 | knitr::opts_chunk$set( 33 | tidy = TRUE, 34 | tidy.opts = list(width.cutoff = 95), 35 | message = FALSE, 36 | warning = FALSE 37 | ) 38 | ``` 39 | 40 | Prerequisites to install: 41 | 42 | * [Seurat](https://satijalab.org/seurat/install) 43 | * [Conos](https://github.com/hms-dbmi/conos) 44 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 45 | * [SeuratData](https://github.com/satijalab/seurat-data) 46 | 47 | ```{r packages} 48 | library(conos) 49 | library(Seurat) 50 | library(SeuratData) 51 | library(SeuratWrappers) 52 | ``` 53 | 54 | ## {.tabset .tabset-pills} 55 | 56 | ### Systematic comparative analysis of human PBMC 57 | 58 | To learn more about this dataset, type `?pbmcsca` 59 | 60 | ```{r pbmcsca, results='hide', cache=TRUE} 61 | InstallData("pbmcsca") 62 | data("pbmcsca") 63 | pbmcsca.panel <- SplitObject(pbmcsca, split.by = 'Method') 64 | for (i in 1:length(pbmcsca.panel)) { 65 | pbmcsca.panel[[i]] <- NormalizeData(pbmcsca.panel[[i]]) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 66 | } 67 | pbmcsca.con <- Conos$new(pbmcsca.panel) 68 | pbmcsca.con$buildGraph( 69 | k = 15, 70 | k.self = 5, 71 | space = 'PCA', 72 | ncomps = 30, 73 | n.odgenes = 2000, 74 | matching.method = 'mNN', 75 | metric = 'angular', 76 | score.component.variance = TRUE, 77 | verbose = TRUE 78 | ) 79 | pbmcsca.con$findCommunities() 80 | pbmcsca.con$embedGraph() 81 | pbmcsca <- as.Seurat(pbmcsca.con) 82 | DimPlot(pbmcsca, reduction = "largeVis", group.by = c("Method", "ident", 'CellType'), ncol = 3) 83 | ``` 84 | 85 | ### Interferon-stimulated and control PBMC 86 | 87 | To learn more about this dataset, type `?ifnb` 88 | 89 | ```{r ifnb, results='hide', cache=TRUE} 90 | InstallData("ifnb") 91 | data("ifnb") 92 | ifnb.panel <- SplitObject(ifnb, split.by = 'stim') 93 | for (i in 1:length(ifnb.panel)) { 94 | ifnb.panel[[i]] <- NormalizeData(ifnb.panel[[i]]) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 95 | } 96 | ifnb.con <- Conos$new(ifnb.panel) 97 | ifnb.con$buildGraph( 98 | k = 15, 99 | k.self = 5, 100 | space = 'PCA', 101 | ncomps = 30, 102 | n.odgenes = 2000, 103 | matching.method = 'mNN', 104 | metric = 'angular', 105 | score.component.variance = TRUE, 106 | verbose = TRUE 107 | ) 108 | ifnb.con$findCommunities() 109 | ifnb.con$embedGraph() 110 | ifnb <- as.Seurat(ifnb.con) 111 | DimPlot(ifnb, reduction = "largeVis", group.by = c("stim", "ident", 'seurat_annotations'), ncol = 3) 112 | ``` 113 | 114 | ### Eight human pancreatic islet datasets 115 | 116 | To learn more about this dataset, type `?panc8` 117 | 118 | ```{r pancreas, results='hide', cache=TRUE} 119 | InstallData("panc8") 120 | data("panc8") 121 | panc8.panel <- SplitObject(panc8, split.by = 'replicate') 122 | for (i in 1:length(panc8.panel)) { 123 | panc8.panel[[i]] <- NormalizeData(panc8.panel[[i]]) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 124 | } 125 | panc8.con <- Conos$new(panc8.panel) 126 | panc8.con$buildGraph( 127 | k = 15, 128 | k.self = 5, 129 | space = 'PCA', 130 | ncomps = 30, 131 | n.odgenes = 2000, 132 | matching.method = 'mNN', 133 | metric = 'angular', 134 | score.component.variance = TRUE, 135 | verbose = TRUE 136 | ) 137 | panc8.con$findCommunities() 138 | panc8.con$embedGraph() 139 | panc8 <- as.Seurat(panc8.con) 140 | DimPlot(panc8, reduction = "largeVis", group.by = c("replicate", "ident", 'celltype'), ncol = 3) 141 | ``` 142 | -------------------------------------------------------------------------------- /docs/conos.md: -------------------------------------------------------------------------------- 1 | Integration of datasets using Conos 2 | ================ 3 | Compiled: July 15, 2019 4 | 5 | - [](#section) 6 | - [Systematic comparative analysis of human PBMC](#systematic-comparative-analysis-of-human-pbmc) 7 | - [Interferon-stimulated and control PBMC](#interferon-stimulated-and-control-pbmc) 8 | - [Eight human pancreatic islet datasets](#eight-human-pancreatic-islet-datasets) 9 | 10 | This vignette demonstrates the use of the Conos package in Seurat. Commands and parameters are based off of the [Conos tutorial](https://github.com/hms-dbmi/conos/blob/master/vignettes/walkthrough.md). If you use Conos in your work, please cite: 11 | 12 | > *Joint analysis of heterogeneous single-cell RNA-seq dataset collections* 13 | > 14 | > Nikolas Barkas, Viktor Petukhov, Daria Nikolaeva, Yaroslav Lozinsky, Samuel Demharter, Konstantin Khodosevich, Peter V. Kharchenko 15 | > 16 | > Nature Methods, 2019. 17 | > 18 | > doi: [10.1038/s41592-019-0466-z](https://doi.org/10.1038/s41592-019-0466-z) 19 | > 20 | > GitHub: 21 | 22 | Prerequisites to install: 23 | 24 | - [Seurat](https://satijalab.org/seurat/install) 25 | - [Conos](https://github.com/hms-dbmi/conos) 26 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 27 | - [SeuratData](https://github.com/satijalab/seurat-data) 28 | 29 | ``` r 30 | library(conos) 31 | library(Seurat) 32 | library(SeuratData) 33 | library(SeuratWrappers) 34 | ``` 35 | 36 | ### Systematic comparative analysis of human PBMC 37 | 38 | To learn more about this dataset, type `?pbmcsca` 39 | 40 | ``` r 41 | InstallData("pbmcsca") 42 | data("pbmcsca") 43 | pbmcsca.panel <- SplitObject(pbmcsca, split.by = "Method") 44 | for (i in 1:length(pbmcsca.panel)) { 45 | pbmcsca.panel[[i]] <- NormalizeData(pbmcsca.panel[[i]]) %>% FindVariableFeatures() %>% ScaleData() %>% 46 | RunPCA(verbose = FALSE) 47 | } 48 | pbmcsca.con <- Conos$new(pbmcsca.panel) 49 | pbmcsca.con$buildGraph(k = 15, k.self = 5, space = "PCA", ncomps = 30, n.odgenes = 2000, matching.method = "mNN", 50 | metric = "angular", score.component.variance = TRUE, verbose = TRUE) 51 | pbmcsca.con$findCommunities() 52 | pbmcsca.con$embedGraph() 53 | pbmcsca <- as.Seurat(pbmcsca.con) 54 | DimPlot(pbmcsca, reduction = "largeVis", group.by = c("Method", "ident", "CellType"), ncol = 3) 55 | ``` 56 | 57 | ![](conos_files/figure-markdown_github/pbmcsca-1.png) 58 | 59 | ### Interferon-stimulated and control PBMC 60 | 61 | To learn more about this dataset, type `?ifnb` 62 | 63 | ``` r 64 | InstallData("ifnb") 65 | data("ifnb") 66 | ifnb.panel <- SplitObject(ifnb, split.by = "stim") 67 | for (i in 1:length(ifnb.panel)) { 68 | ifnb.panel[[i]] <- NormalizeData(ifnb.panel[[i]]) %>% FindVariableFeatures() %>% ScaleData() %>% 69 | RunPCA(verbose = FALSE) 70 | } 71 | ifnb.con <- Conos$new(ifnb.panel) 72 | ifnb.con$buildGraph(k = 15, k.self = 5, space = "PCA", ncomps = 30, n.odgenes = 2000, matching.method = "mNN", 73 | metric = "angular", score.component.variance = TRUE, verbose = TRUE) 74 | ifnb.con$findCommunities() 75 | ifnb.con$embedGraph() 76 | ifnb <- as.Seurat(ifnb.con) 77 | DimPlot(ifnb, reduction = "largeVis", group.by = c("stim", "ident", "seurat_annotations"), ncol = 3) 78 | ``` 79 | 80 | ![](conos_files/figure-markdown_github/ifnb-1.png) 81 | 82 | ### Eight human pancreatic islet datasets 83 | 84 | To learn more about this dataset, type `?panc8` 85 | 86 | ``` r 87 | InstallData("panc8") 88 | data("panc8") 89 | panc8.panel <- SplitObject(panc8, split.by = "replicate") 90 | for (i in 1:length(panc8.panel)) { 91 | panc8.panel[[i]] <- NormalizeData(panc8.panel[[i]]) %>% FindVariableFeatures() %>% ScaleData() %>% 92 | RunPCA(verbose = FALSE) 93 | } 94 | panc8.con <- Conos$new(panc8.panel) 95 | panc8.con$buildGraph(k = 15, k.self = 5, space = "PCA", ncomps = 30, n.odgenes = 2000, matching.method = "mNN", 96 | metric = "angular", score.component.variance = TRUE, verbose = TRUE) 97 | panc8.con$findCommunities() 98 | panc8.con$embedGraph() 99 | panc8 <- as.Seurat(panc8.con) 100 | DimPlot(panc8, reduction = "largeVis", group.by = c("replicate", "ident", "celltype"), ncol = 3) 101 | ``` 102 | 103 | ![](conos_files/figure-markdown_github/pancreas-1.png) 104 | -------------------------------------------------------------------------------- /docs/conos_files/figure-markdown_github/ifnb-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/conos_files/figure-markdown_github/ifnb-1.png -------------------------------------------------------------------------------- /docs/conos_files/figure-markdown_github/pancreas-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/conos_files/figure-markdown_github/pancreas-1.png -------------------------------------------------------------------------------- /docs/conos_files/figure-markdown_github/pbmcsca-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/conos_files/figure-markdown_github/pbmcsca-1.png -------------------------------------------------------------------------------- /docs/fast_mnn.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Running fastMNN on Seurat Objects" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: true 7 | toc: true 8 | toc_depth: 3 9 | fig_width: 16 10 | html_document: 11 | df_print: kable 12 | theme: united 13 | fig_height: 5 14 | fig_width: 16 15 | out_height: 4 16 | --- 17 | 18 | This vigettte demonstrates how to run fastMNN on Seurat objects. Parameters and commands are based off of the [fastMNN help page](https://rdrr.io/github/LTLA/batchelor/man/fastMNN.html). If you use fastMNN, please cite: 19 | 20 | > *Batch effects in single-cell RNA-sequencing data are corrected by matching mutual nearest neighbors* 21 | > 22 | > Laleh Haghverdi, Aaron T L Lun, Michael D Morgan & John C Marioni 23 | > 24 | > Nature Biotechnology, 2018 25 | > 26 | > doi: [10.1038/nbt.4091](https://doi.org/10.1038/nbt.4091) 27 | > 28 | > Bioconductor: https://bioconductor.org/packages/release/bioc/html/batchelor.html 29 | 30 | ```{r setup, include=FALSE} 31 | knitr::opts_chunk$set( 32 | tidy = TRUE, 33 | tidy.opts = list(width.cutoff = 95), 34 | message = FALSE, 35 | warning = FALSE 36 | ) 37 | options(timeout = 1000) 38 | ``` 39 | 40 | Prerequisites to install: 41 | 42 | * [Seurat](https://satijalab.org/seurat/install) 43 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 44 | * [SeuratData](https://github.com/satijalab/seurat-data) 45 | 46 | ```{r packages} 47 | library(Seurat) 48 | library(SeuratData) 49 | library(SeuratWrappers) 50 | ``` 51 | 52 | ## {.tabset .tabset-pills} 53 | 54 | ### Systematic comparative analysis of human PBMC 55 | 56 | To learn more about this dataset, type `?pbmcsca` 57 | 58 | ```{r pbmcsca, results='hide'} 59 | InstallData("pbmcsca") 60 | data("pbmcsca") 61 | pbmcsca <- NormalizeData(pbmcsca) 62 | pbmcsca <- FindVariableFeatures(pbmcsca) 63 | pbmcsca <- RunFastMNN(object.list = SplitObject(pbmcsca, split.by = 'Method')) 64 | pbmcsca <- RunUMAP(pbmcsca, reduction = 'mnn', dims = 1:30) 65 | pbmcsca <- FindNeighbors(pbmcsca, reduction = 'mnn', dims = 1:30) 66 | pbmcsca <- FindClusters(pbmcsca) 67 | DimPlot(pbmcsca, group.by = c('Method', 'ident',"CellType"), ncol = 3) 68 | ``` 69 | 70 | ```{r cleanup_pbmcsca, include=FALSE} 71 | rm(pbmcsca) 72 | gc(verbose = FALSE) 73 | ``` 74 | 75 | ### Interferon-stimulated and control PBMC 76 | 77 | To learn more about this dataset, type `?ifnb` 78 | 79 | ```{r ifnb_stim, results='hide'} 80 | InstallData("ifnb") 81 | data("ifnb") 82 | ifnb <- NormalizeData(ifnb) 83 | ifnb <- FindVariableFeatures(ifnb) 84 | ifnb <- RunFastMNN(object.list = SplitObject(ifnb, split.by = 'stim')) 85 | ifnb <- RunUMAP(ifnb, reduction = 'mnn', dims = 1:30) 86 | ifnb <- FindNeighbors(ifnb, reduction = 'mnn', dims = 1:30) 87 | ifnb <- FindClusters(ifnb) 88 | DimPlot(ifnb, group.by = c('stim', 'ident', 'seurat_annotations'), ncol = 3) 89 | ``` 90 | 91 | ```{r cleanup_ifnb, include=FALSE} 92 | rm(ifnb) 93 | gc(verbose = FALSE) 94 | ``` 95 | 96 | ### Eight human pancreatic islet datasets 97 | 98 | To learn more about this dataset, type `?panc8` 99 | 100 | ```{r pancreas, results='hide'} 101 | InstallData("panc8") 102 | data("panc8") 103 | panc8 <- NormalizeData(panc8) 104 | panc8 <- FindVariableFeatures(panc8) 105 | panc8 <- RunFastMNN(object.list = SplitObject(panc8, split.by = 'replicate')[c("celseq", "celseq2", "fluidigmc1", "smartseq2")]) 106 | panc8 <- RunUMAP(panc8, reduction = 'mnn', dims = 1:30) 107 | panc8 <- FindNeighbors(panc8, reduction = 'mnn', dims = 1:30) 108 | panc8 <- FindClusters(panc8) 109 | DimPlot(panc8, group.by = c('replicate', 'ident', 'celltype'), ncol = 3) 110 | ``` 111 | -------------------------------------------------------------------------------- /docs/fast_mnn.md: -------------------------------------------------------------------------------- 1 | Running fastMNN on Seurat Objects 2 | ================ 3 | Compiled: June 23, 2021 4 | 5 | - [](#section) 6 | - [Systematic comparative analysis of human 7 | PBMC](#systematic-comparative-analysis-of-human-pbmc) 8 | - [Interferon-stimulated and control 9 | PBMC](#interferon-stimulated-and-control-pbmc) 10 | - [Eight human pancreatic islet 11 | datasets](#eight-human-pancreatic-islet-datasets) 12 | 13 | This vigettte demonstrates how to run fastMNN on Seurat objects. 14 | Parameters and commands are based off of the [fastMNN help 15 | page](https://rdrr.io/github/LTLA/batchelor/man/fastMNN.html). If you 16 | use fastMNN, please cite: 17 | 18 | > *Batch effects in single-cell RNA-sequencing data are corrected by 19 | > matching mutual nearest neighbors* 20 | > 21 | > Laleh Haghverdi, Aaron T L Lun, Michael D Morgan & John C Marioni 22 | > 23 | > Nature Biotechnology, 2018 24 | > 25 | > doi: [10.1038/nbt.4091](https://doi.org/10.1038/nbt.4091) 26 | > 27 | > Bioconductor: 28 | > 29 | 30 | Prerequisites to install: 31 | 32 | - [Seurat](https://satijalab.org/seurat/install) 33 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 34 | - [SeuratData](https://github.com/satijalab/seurat-data) 35 | 36 | 37 | 38 | ``` r 39 | library(Seurat) 40 | library(SeuratData) 41 | library(SeuratWrappers) 42 | ``` 43 | 44 | ## 45 | 46 | ### Systematic comparative analysis of human PBMC 47 | 48 | To learn more about this dataset, type `?pbmcsca` 49 | 50 | ``` r 51 | InstallData("pbmcsca") 52 | data("pbmcsca") 53 | pbmcsca <- NormalizeData(pbmcsca) 54 | pbmcsca <- FindVariableFeatures(pbmcsca) 55 | pbmcsca <- RunFastMNN(object.list = SplitObject(pbmcsca, split.by = "Method")) 56 | pbmcsca <- RunUMAP(pbmcsca, reduction = "mnn", dims = 1:30) 57 | pbmcsca <- FindNeighbors(pbmcsca, reduction = "mnn", dims = 1:30) 58 | pbmcsca <- FindClusters(pbmcsca) 59 | DimPlot(pbmcsca, group.by = c("Method", "ident", "CellType"), ncol = 3) 60 | ``` 61 | 62 | ![](/__w/seurat-wrappers/seurat-wrappers/test-build/fast_mnn_files/figure-gfm/pbmcsca-1.png) 63 | 64 | ### Interferon-stimulated and control PBMC 65 | 66 | To learn more about this dataset, type `?ifnb` 67 | 68 | ``` r 69 | InstallData("ifnb") 70 | data("ifnb") 71 | ifnb <- NormalizeData(ifnb) 72 | ifnb <- FindVariableFeatures(ifnb) 73 | ifnb <- RunFastMNN(object.list = SplitObject(ifnb, split.by = "stim")) 74 | ifnb <- RunUMAP(ifnb, reduction = "mnn", dims = 1:30) 75 | ifnb <- FindNeighbors(ifnb, reduction = "mnn", dims = 1:30) 76 | ifnb <- FindClusters(ifnb) 77 | DimPlot(ifnb, group.by = c("stim", "ident", "seurat_annotations"), ncol = 3) 78 | ``` 79 | 80 | ![](/__w/seurat-wrappers/seurat-wrappers/test-build/fast_mnn_files/figure-gfm/ifnb_stim-1.png) 81 | 82 | ### Eight human pancreatic islet datasets 83 | 84 | To learn more about this dataset, type `?panc8` 85 | 86 | ``` r 87 | InstallData("panc8") 88 | data("panc8") 89 | panc8 <- NormalizeData(panc8) 90 | panc8 <- FindVariableFeatures(panc8) 91 | panc8 <- RunFastMNN(object.list = SplitObject(panc8, split.by = "replicate")[c("celseq", "celseq2", 92 | "fluidigmc1", "smartseq2")]) 93 | panc8 <- RunUMAP(panc8, reduction = "mnn", dims = 1:30) 94 | panc8 <- FindNeighbors(panc8, reduction = "mnn", dims = 1:30) 95 | panc8 <- FindClusters(panc8) 96 | DimPlot(panc8, group.by = c("replicate", "ident", "celltype"), ncol = 3) 97 | ``` 98 | 99 | ![](/__w/seurat-wrappers/seurat-wrappers/test-build/fast_mnn_files/figure-gfm/pancreas-1.png) 100 | -------------------------------------------------------------------------------- /docs/fast_mnn_files/figure-gfm/ifnb_stim-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/fast_mnn_files/figure-gfm/ifnb_stim-1.png -------------------------------------------------------------------------------- /docs/fast_mnn_files/figure-gfm/pancreas-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/fast_mnn_files/figure-gfm/pancreas-1.png -------------------------------------------------------------------------------- /docs/fast_mnn_files/figure-gfm/pbmcsca-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/fast_mnn_files/figure-gfm/pbmcsca-1.png -------------------------------------------------------------------------------- /docs/glmpca.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Running GLM-PCA on a Seurat Object" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: false 7 | toc: false 8 | html_document: 9 | df_print: kable 10 | theme: united 11 | --- 12 | 13 | This vignette demonstrates how to run GLM-PCA, which implements a generalized version of PCA for non-normally distributed data, on a Seurat object. If you use this, please cite: 14 | 15 | > *Feature selection and dimension reduction for single-cell RNA-Seq based on a multinomial model* 16 | > 17 | > F. William Townes, Stephanie C. Hicks, Martin J. Aryee & Rafael A. Irizarry 18 | > 19 | > Genome Biology, 2019 20 | > 21 | > doi: https://doi.org/10.1186/s13059-019-1861-6 22 | > 23 | > GitHub: https://github.com/willtownes/glmpca 24 | > CRAN: https://cran.r-project.org/web/packages/glmpca/index.html 25 | 26 | ```{r setup, include=FALSE} 27 | knitr::opts_chunk$set( 28 | message = FALSE, 29 | warning = FALSE, 30 | fig.width = 10 31 | ) 32 | ``` 33 | 34 | Prerequisites to install: 35 | 36 | * [Seurat](https://satijalab.org/seurat/install) 37 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 38 | * [SeuratData](https://github.com/satijalab/seurat-data) 39 | * [glmpca](https://github.com/willtownes/glmpca) 40 | * [scry](https://github.com/kstreet13/scry) 41 | 42 | ```{r packages} 43 | library(Seurat) 44 | library(SeuratData) 45 | library(SeuratWrappers) 46 | library(glmpca) 47 | library(scry) 48 | ``` 49 | 50 | ### GLM-PCA on PBMC3k 51 | 52 | To learn more about this dataset, type `?pbmc3k` 53 | 54 | ```{r glmpca, cache=TRUE, cache.lazy=TRUE} 55 | InstallData("pbmc3k") 56 | data("pbmc3k") 57 | 58 | # Initial processing to select variable features 59 | m <- GetAssayData(pbmc3k, slot = "counts", assay = "RNA") 60 | devs <- scry::devianceFeatureSelection(m) 61 | dev_ranked_genes <- rownames(pbmc3k)[order(devs, decreasing = TRUE)] 62 | topdev <- head(dev_ranked_genes, 2000) 63 | 64 | # run GLM-PCA on Seurat object. 65 | # Uses Poisson model by default 66 | # Note that data in the counts slot is used 67 | # We choose 10 dimensions for computational efficiency 68 | 69 | ndims <- 10 70 | pbmc3k <- RunGLMPCA(pbmc3k, features = topdev, L = ndims) 71 | pbmc3k <- FindNeighbors(pbmc3k, reduction = 'glmpca', dims = 1:ndims, verbose = FALSE) 72 | pbmc3k <- FindClusters(pbmc3k, verbose = FALSE) 73 | pbmc3k <- RunUMAP(pbmc3k, reduction = 'glmpca', dims = 1:ndims, verbose = FALSE) 74 | ``` 75 | 76 | ```{r explore, fig.width=6} 77 | # visualize markers 78 | features.plot <- c('CD3D', 'MS4A1', 'CD8A', 'GZMK', 'GZMB', 'FCGR3A') 79 | DimPlot(pbmc3k) 80 | ``` 81 | 82 | Do the learned clusters overlap with the original annotation? 83 | 84 | ```{r} 85 | with(pbmc3k[[]], table(seurat_annotations, seurat_clusters)) 86 | ``` 87 | 88 | ```{r explore2, fig.height=10} 89 | pbmc3k <- NormalizeData(pbmc3k, verbose = FALSE) 90 | FeaturePlot(pbmc3k, features.plot, ncol = 2) 91 | ``` 92 | -------------------------------------------------------------------------------- /docs/glmpca.md: -------------------------------------------------------------------------------- 1 | Running GLM-PCA on a Seurat Object 2 | ================ 3 | Compiled: July 15, 2020 4 | 5 | This vignette demonstrates how to run GLM-PCA, which implements a 6 | generalized version of PCA for non-normally distributed data, on a 7 | Seurat object. If you use this, please cite: 8 | 9 | > *Feature selection and dimension reduction for single-cell RNA-Seq 10 | > based on a multinomial model* 11 | > 12 | > F. William Townes, Stephanie C. Hicks, Martin J. Aryee & Rafael A. 13 | > Irizarry 14 | > 15 | > Genome Biology, 2019 16 | > 17 | > doi: 18 | > 19 | > GitHub: CRAN: 20 | > 21 | 22 | Prerequisites to install: 23 | 24 | - [Seurat](https://satijalab.org/seurat/install) 25 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 26 | - [SeuratData](https://github.com/satijalab/seurat-data) 27 | - [glmpca](https://github.com/willtownes/glmpca) 28 | - [scry](https://github.com/kstreet13/scry) 29 | 30 | 31 | 32 | ``` r 33 | library(Seurat) 34 | library(SeuratData) 35 | library(SeuratWrappers) 36 | library(glmpca) 37 | library(scry) 38 | ``` 39 | 40 | ### GLM-PCA on PBMC3k 41 | 42 | To learn more about this dataset, type `?pbmc3k` 43 | 44 | ``` r 45 | InstallData("pbmc3k") 46 | data("pbmc3k") 47 | 48 | # Initial processing to select variable features 49 | m <- GetAssayData(pbmc3k, slot = "counts", assay = "RNA") 50 | devs <- scry::devianceFeatureSelection(m) 51 | dev_ranked_genes <- rownames(pbmc3k)[order(devs, decreasing = TRUE)] 52 | topdev <- head(dev_ranked_genes, 2000) 53 | 54 | # run GLM-PCA on Seurat object. 55 | # Uses Poisson model by default 56 | # Note that data in the counts slot is used 57 | # We choose 10 dimensions for computational efficiency 58 | 59 | ndims <- 10 60 | pbmc3k <- RunGLMPCA(pbmc3k, features = topdev, L = ndims) 61 | pbmc3k <- FindNeighbors(pbmc3k, reduction = 'glmpca', dims = 1:ndims, verbose = FALSE) 62 | pbmc3k <- FindClusters(pbmc3k, verbose = FALSE) 63 | pbmc3k <- RunUMAP(pbmc3k, reduction = 'glmpca', dims = 1:ndims, verbose = FALSE) 64 | ``` 65 | 66 | ``` r 67 | # visualize markers 68 | features.plot <- c('CD3D', 'MS4A1', 'CD8A', 'GZMK', 'GZMB', 'FCGR3A') 69 | DimPlot(pbmc3k) 70 | ``` 71 | 72 | ![](glmpca_files/figure-markdown_github/explore-1.png) 73 | 74 | Do the learned clusters overlap with the original annotation? 75 | 76 | ``` r 77 | with(pbmc3k[[]], table(seurat_annotations, seurat_clusters)) 78 | ``` 79 | 80 | ## seurat_clusters 81 | ## seurat_annotations 0 1 2 3 4 5 6 7 8 82 | ## Naive CD4 T 168 484 0 3 42 0 0 0 0 83 | ## Memory CD4 T 405 45 0 0 30 0 0 0 3 84 | ## CD14+ Mono 0 0 469 0 0 8 0 3 0 85 | ## B 0 0 0 344 0 0 0 0 0 86 | ## CD8 T 7 0 0 0 254 0 9 0 1 87 | ## FCGR3A+ Mono 0 0 12 0 0 150 0 0 0 88 | ## NK 0 0 0 0 8 0 147 0 0 89 | ## DC 0 0 2 2 0 0 1 27 0 90 | ## Platelet 0 0 1 0 0 0 0 0 13 91 | 92 | ``` r 93 | pbmc3k <- NormalizeData(pbmc3k, verbose = FALSE) 94 | FeaturePlot(pbmc3k, features.plot, ncol = 2) 95 | ``` 96 | 97 | ![](glmpca_files/figure-markdown_github/explore2-1.png) 98 | -------------------------------------------------------------------------------- /docs/glmpca_files/figure-markdown_github/explore-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/glmpca_files/figure-markdown_github/explore-1.png -------------------------------------------------------------------------------- /docs/glmpca_files/figure-markdown_github/explore2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/glmpca_files/figure-markdown_github/explore2-1.png -------------------------------------------------------------------------------- /docs/harmony.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Integration of datasets using Harmony" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: true 7 | toc: true 8 | toc_depth: 3 9 | fig_width: 16 10 | html_document: 11 | df_print: kable 12 | theme: united 13 | fig_height: 5 14 | fig_width: 16 15 | out_height: 4 16 | --- 17 | 18 | This vigettte demonstrates the use of the Harmony package in Seurat. Commands and parameters are based off of the [Harmony use page](https://github.com/immunogenomics/harmony). If you use Harmony in your work, please cite: 19 | 20 | > *Fast, sensitive, and flexible integration of single cell data with Harmony* 21 | > 22 | > Ilya Korsunsky, Jean Fan, Kamil Slowikowski, Fan Zhang, Kevin Wei, Yuriy Baglaenko, Michael Brenner, Po-Ru Loh, Soumya Raychaudhuri 23 | > 24 | > bioRxiv, 2019 25 | > 26 | > doi: [10.1101/461954v2](https://www.biorxiv.org/content/10.1101/461954v2) 27 | > 28 | > GitHub: https://github.com/immunogenomics/harmony 29 | 30 | ```{r setup, include=FALSE} 31 | knitr::opts_chunk$set( 32 | tidy = TRUE, 33 | tidy.opts = list(width.cutoff = 95), 34 | message = FALSE, 35 | warning = FALSE 36 | ) 37 | ``` 38 | 39 | Prerequisites to install: 40 | 41 | * [Seurat](https://satijalab.org/seurat/install) 42 | * [Harmony](https://github.com/immunogenomics/harmony) 43 | * [SeuratData](https://github.com/satijalab/seurat-data) 44 | 45 | Note that SeuratWrappers is not necessary, as the wrapper functions were generously provided by the Harmony authors, and are included when installing Harmony. 46 | 47 | ```{r packages} 48 | library(harmony) 49 | library(Seurat) 50 | library(SeuratData) 51 | ``` 52 | 53 | ## {.tabset .tabset-pills} 54 | 55 | ### Systematic comparative analysis of human PBMC 56 | 57 | To learn more about this dataset, type `?pbmcsca` 58 | 59 | ```{r pbmcsca, results='hide', cache=TRUE} 60 | InstallData("pbmcsca") 61 | data("pbmcsca") 62 | pbmcsca <- NormalizeData(pbmcsca) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 63 | pbmcsca <- RunHarmony(pbmcsca, group.by.vars = 'Method') 64 | pbmcsca <- RunUMAP(pbmcsca, reduction = 'harmony', dims = 1:30) 65 | pbmcsca <- FindNeighbors(pbmcsca, reduction = 'harmony', dims = 1:30) %>% FindClusters() 66 | DimPlot(pbmcsca, group.by = c('Method', 'ident',"CellType"), ncol = 3) 67 | ``` 68 | 69 | ### Interferon-stimulated and control PBMC 70 | 71 | To learn more about this dataset, type `?ifnb` 72 | 73 | ```{r ifnb_stim, results='hide', cache=TRUE} 74 | InstallData("ifnb") 75 | data("ifnb") 76 | ifnb <- NormalizeData(ifnb) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 77 | ifnb <- RunHarmony(ifnb, group.by.vars = 'stim') 78 | ifnb <- RunUMAP(ifnb, reduction = 'harmony', dims = 1:30) 79 | ifnb <- FindNeighbors(ifnb, reduction = 'harmony', dims = 1:30) %>% FindClusters() 80 | DimPlot(ifnb, group.by = c("stim", "ident", "seurat_annotations"), ncol = 3) 81 | ``` 82 | 83 | ### Eight human pancreatic islet datasets 84 | 85 | To learn more about this dataset, type `?panc8` 86 | 87 | ```{r pancreas, results='hide', cache=TRUE} 88 | InstallData("panc8") 89 | data("panc8") 90 | panc8 <- NormalizeData(panc8) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 91 | panc8 <- RunHarmony(panc8, group.by.vars = 'replicate') 92 | panc8 <- RunUMAP(panc8, reduction = 'harmony', dims = 1:30) 93 | panc8 <- FindNeighbors(panc8, reduction = 'harmony', dims = 1:30) %>% FindClusters() 94 | DimPlot(panc8, group.by = c("replicate", "ident","celltype"), ncol = 3) 95 | ``` 96 | -------------------------------------------------------------------------------- /docs/harmony.md: -------------------------------------------------------------------------------- 1 | Integration of datasets using Harmony 2 | ================ 3 | Compiled: July 15, 2019 4 | 5 | - [](#section) 6 | - [Systematic comparative analysis of human PBMC](#systematic-comparative-analysis-of-human-pbmc) 7 | - [Interferon-stimulated and control PBMC](#interferon-stimulated-and-control-pbmc) 8 | - [Eight human pancreatic islet datasets](#eight-human-pancreatic-islet-datasets) 9 | 10 | This vigettte demonstrates the use of the Harmony package in Seurat. Commands and parameters are based off of the [Harmony use page](https://github.com/immunogenomics/harmony). If you use Harmony in your work, please cite: 11 | 12 | > *Fast, sensitive, and flexible integration of single cell data with Harmony* 13 | > 14 | > Ilya Korsunsky, Jean Fan, Kamil Slowikowski, Fan Zhang, Kevin Wei, Yuriy Baglaenko, Michael Brenner, Po-Ru Loh, Soumya Raychaudhuri 15 | > 16 | > bioRxiv, 2019 17 | > 18 | > doi: [10.1101/461954v2](https://www.biorxiv.org/content/10.1101/461954v2) 19 | > 20 | > GitHub: 21 | 22 | Prerequisites to install: 23 | 24 | - [Seurat](https://satijalab.org/seurat/install) 25 | - [Harmony](https://github.com/immunogenomics/harmony) 26 | - [SeuratData](https://github.com/satijalab/seurat-data) 27 | 28 | Note that SeuratWrappers is not necessary, as the wrapper functions were generously provided by the Harmony authors, and are included when installing Harmony. 29 | 30 | ``` r 31 | library(harmony) 32 | library(Seurat) 33 | library(SeuratData) 34 | ``` 35 | 36 | ### Systematic comparative analysis of human PBMC 37 | 38 | To learn more about this dataset, type `?pbmcsca` 39 | 40 | ``` r 41 | InstallData("pbmcsca") 42 | data("pbmcsca") 43 | pbmcsca <- NormalizeData(pbmcsca) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 44 | pbmcsca <- RunHarmony(pbmcsca, group.by.vars = "Method") 45 | pbmcsca <- RunUMAP(pbmcsca, reduction = "harmony", dims = 1:30) 46 | pbmcsca <- FindNeighbors(pbmcsca, reduction = "harmony", dims = 1:30) %>% FindClusters() 47 | DimPlot(pbmcsca, group.by = c("Method", "ident", "CellType"), ncol = 3) 48 | ``` 49 | 50 | ![](harmony_files/figure-markdown_github/pbmcsca-1.png) 51 | 52 | ### Interferon-stimulated and control PBMC 53 | 54 | To learn more about this dataset, type `?ifnb` 55 | 56 | ``` r 57 | InstallData("ifnb") 58 | data("ifnb") 59 | ifnb <- NormalizeData(ifnb) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 60 | ifnb <- RunHarmony(ifnb, group.by.vars = "stim") 61 | ifnb <- RunUMAP(ifnb, reduction = "harmony", dims = 1:30) 62 | ifnb <- FindNeighbors(ifnb, reduction = "harmony", dims = 1:30) %>% FindClusters() 63 | DimPlot(ifnb, group.by = c("stim", "ident", "seurat_annotations"), ncol = 3) 64 | ``` 65 | 66 | ![](harmony_files/figure-markdown_github/ifnb_stim-1.png) 67 | 68 | ### Eight human pancreatic islet datasets 69 | 70 | To learn more about this dataset, type `?panc8` 71 | 72 | ``` r 73 | InstallData("panc8") 74 | data("panc8") 75 | panc8 <- NormalizeData(panc8) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA(verbose = FALSE) 76 | panc8 <- RunHarmony(panc8, group.by.vars = "replicate") 77 | panc8 <- RunUMAP(panc8, reduction = "harmony", dims = 1:30) 78 | panc8 <- FindNeighbors(panc8, reduction = "harmony", dims = 1:30) %>% FindClusters() 79 | DimPlot(panc8, group.by = c("replicate", "ident", "celltype"), ncol = 3) 80 | ``` 81 | 82 | ![](harmony_files/figure-markdown_github/pancreas-1.png) 83 | -------------------------------------------------------------------------------- /docs/harmony_files/figure-markdown_github/ifnb_stim-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/harmony_files/figure-markdown_github/ifnb_stim-1.png -------------------------------------------------------------------------------- /docs/harmony_files/figure-markdown_github/pancreas-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/harmony_files/figure-markdown_github/pancreas-1.png -------------------------------------------------------------------------------- /docs/harmony_files/figure-markdown_github/pbmcsca-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/harmony_files/figure-markdown_github/pbmcsca-1.png -------------------------------------------------------------------------------- /docs/liger.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Integrating Seurat objects using LIGER" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: true 7 | toc: true 8 | toc_depth: 3 9 | fig_width: 16 10 | html_document: 11 | df_print: kable 12 | theme: united 13 | fig_height: 5 14 | fig_width: 16 15 | out_height: 4 16 | --- 17 | 18 | NOTE: Please update your `liger` version to 0.5.0 or above before following this tutorial. 19 | 20 | This vigettte demonstrates how to run LIGER on Seurat objects. Parameters and commands are based on the [LIGER tutorial](http://htmlpreview.github.io/?https://github.com/MacoskoLab/liger/blob/master/vignettes/Integrating_multi_scRNA_data.html). If you use LIGER, please cite: 21 | 22 | > *Single-Cell Multi-omic Integration Compares and Contrasts Features of Brain Cell Identity* 23 | > 24 | > Joshua Welch, Velina Kozareva, Ashley Ferreira, Charles Vanderburg, Carly Martin, Evan Z.Macosko 25 | > 26 | > Cell, 2019. 27 | > 28 | > doi: [10.1016/j.cell.2019.05.006](https://doi.org/10.1016/j.cell.2019.05.006) 29 | > 30 | > GitHub: https://github.com/MacoskoLab/liger 31 | 32 | ```{r setup, include=FALSE} 33 | knitr::opts_chunk$set( 34 | tidy = TRUE, 35 | tidy.opts = list(width.cutoff = 95), 36 | message = FALSE, 37 | warning = FALSE 38 | ) 39 | ``` 40 | 41 | Prerequisites to install: 42 | 43 | * [Seurat](https://satijalab.org/seurat/install) 44 | * [LIGER](https://github.com/MacoskoLab/liger) 45 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 46 | * [SeuratData](https://github.com/satijalab/seurat-data) 47 | 48 | ```{r check, include=FALSE} 49 | tryCatch( 50 | expr = SeuratWrappers:::CheckPackage("rliger", "cran"), 51 | error = { 52 | install.packages("rliger") 53 | } 54 | ) 55 | ``` 56 | 57 | ```{r packages} 58 | library(rliger) 59 | library(Seurat) 60 | library(SeuratData) 61 | library(SeuratWrappers) 62 | ``` 63 | 64 | In order to replicate LIGER's multi-dataset functionality, we will use the `split.by` parameter to preprocess the Seurat object on subsets of the data belonging to each dataset separately. Also, as LIGER does not center data when scaling, we will skip that step as well. 65 | 66 | `RunQuantileNorm` produces joint clusters, but users can also optionally perform Louvain community detection (`FindNeighbors` and `FindClusters`) on the integrated latent space from iNMF. 67 | 68 | ## {.tabset .tabset-pills} 69 | 70 | ### Systematic comparative analysis of human PBMC 71 | 72 | To learn more about this dataset, type `?pbmcsca` 73 | 74 | ```{r pbmcsca, results='hide', fig.height = 6, fig.width = 18} 75 | InstallData("pbmcsca") 76 | data("pbmcsca") 77 | # Please update your `liger` version to 0.5.0 or above before following this tutorial 78 | pbmcsca <- NormalizeData(pbmcsca) 79 | pbmcsca <- FindVariableFeatures(pbmcsca) 80 | pbmcsca <- ScaleData(pbmcsca, split.by = 'Method', do.center = FALSE) 81 | pbmcsca <- RunOptimizeALS(pbmcsca, k = 20, lambda = 5, split.by = 'Method') 82 | pbmcsca <- RunQuantileNorm(pbmcsca, split.by = 'Method') 83 | # You can optionally perform Louvain clustering (`FindNeighbors` and `FindClusters`) after `RunQuantileNorm` according to your needs 84 | pbmcsca <- FindNeighbors(pbmcsca, reduction = 'iNMF', dims = 1:20) 85 | pbmcsca <- FindClusters(pbmcsca, resolution = 0.3) 86 | # Dimensional reduction and plotting 87 | pbmcsca <- RunUMAP(pbmcsca, dims = 1:ncol(pbmcsca[['iNMF']]), reduction = 'iNMF') 88 | DimPlot(pbmcsca, group.by = c('Method', 'ident', 'CellType'), ncol = 3) 89 | ``` 90 | 91 | ### Interferon-stimulated and control PBMC 92 | 93 | To learn more about this dataset, type `?ifnb` 94 | 95 | ```{r ifnb, results='hide', fig.height = 6, fig.width = 18} 96 | InstallData("ifnb") 97 | data("ifnb") 98 | # Please update your `liger` version to 0.5.0 or above before following this tutorial. 99 | ifnb <- NormalizeData(ifnb) 100 | ifnb <- FindVariableFeatures(ifnb) 101 | ifnb <- ScaleData(ifnb, split.by = 'stim', do.center = FALSE) 102 | ifnb <- RunOptimizeALS(ifnb, k = 20, lambda = 5, split.by = 'stim') 103 | ifnb <- RunQuantileNorm(ifnb, split.by = 'stim') 104 | # You can optionally perform Louvain clustering (`FindNeighbors` and `FindClusters`) after `RunQuantileNorm` according to your needs 105 | ifnb <- FindNeighbors(ifnb, reduction = 'iNMF', dims = 1:20) 106 | ifnb <- FindClusters(ifnb, resolution = 0.55) 107 | # Dimensional reduction and plotting 108 | ifnb <- RunUMAP(ifnb, dims = 1:ncol(ifnb[['iNMF']]), reduction = 'iNMF') 109 | DimPlot(ifnb, group.by = c('stim', 'ident', 'seurat_annotations'), ncol = 3) 110 | ``` 111 | 112 | ### Eight human pancreatic islet datasets 113 | 114 | To learn more about this dataset, type `?panc8` 115 | 116 | ```{r pancreas, results='hide', fig.height = 6, fig.width = 18} 117 | InstallData("panc8") 118 | data("panc8") 119 | # Please update your `liger` version to 0.5.0 or above before following this tutorial. 120 | panc8 <- NormalizeData(panc8) 121 | panc8 <- FindVariableFeatures(panc8) 122 | panc8 <- ScaleData(panc8, split.by = 'replicate', do.center = FALSE) 123 | panc8 <- RunOptimizeALS(panc8, k = 20, lambda = 5, split.by = 'replicate') 124 | panc8 <- RunQuantileNorm(panc8, split.by = 'replicate') 125 | # You can optionally perform Louvain clustering (`FindNeighbors` and `FindClusters`) after `RunQuantileNorm` according to your needs 126 | panc8 <- FindNeighbors(panc8, reduction = 'iNMF', dims = 1:20) 127 | panc8 <- FindClusters(panc8, resolution = 0.4) 128 | # Dimensional reduction and plotting 129 | panc8 <- RunUMAP(panc8, dims = 1:ncol(panc8[['iNMF']]), reduction = 'iNMF') 130 | DimPlot(panc8, group.by = c('replicate', 'ident', 'celltype'), ncol = 3) 131 | ``` 132 | -------------------------------------------------------------------------------- /docs/liger.md: -------------------------------------------------------------------------------- 1 | Integrating Seurat objects using LIGER 2 | ================ 3 | Compiled: May 25, 2021 4 | 5 | - [](#section) 6 | - [Systematic comparative analysis of human 7 | PBMC](#systematic-comparative-analysis-of-human-pbmc) 8 | - [Interferon-stimulated and control 9 | PBMC](#interferon-stimulated-and-control-pbmc) 10 | - [Eight human pancreatic islet 11 | datasets](#eight-human-pancreatic-islet-datasets) 12 | 13 | NOTE: Please update your `liger` version to 0.5.0 or above before 14 | following this tutorial. 15 | 16 | This vigettte demonstrates how to run LIGER on Seurat objects. 17 | Parameters and commands are based on the [LIGER 18 | tutorial](http://htmlpreview.github.io/?https://github.com/MacoskoLab/liger/blob/master/vignettes/Integrating_multi_scRNA_data.html). 19 | If you use LIGER, please cite: 20 | 21 | > *Single-Cell Multi-omic Integration Compares and Contrasts Features of 22 | > Brain Cell Identity* 23 | > 24 | > Joshua Welch, Velina Kozareva, Ashley Ferreira, Charles Vanderburg, 25 | > Carly Martin, Evan Z.Macosko 26 | > 27 | > Cell, 2019. 28 | > 29 | > doi: 30 | > [10.1016/j.cell.2019.05.006](https://doi.org/10.1016/j.cell.2019.05.006) 31 | > 32 | > GitHub: 33 | 34 | Prerequisites to install: 35 | 36 | - [Seurat](https://satijalab.org/seurat/install) 37 | - [LIGER](https://github.com/MacoskoLab/liger) 38 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 39 | - [SeuratData](https://github.com/satijalab/seurat-data) 40 | 41 | 42 | 43 | ``` r 44 | library(rliger) 45 | library(Seurat) 46 | library(SeuratData) 47 | library(SeuratWrappers) 48 | ``` 49 | 50 | In order to replicate LIGER’s multi-dataset functionality, we will use 51 | the `split.by` parameter to preprocess the Seurat object on subsets of 52 | the data belonging to each dataset separately. Also, as LIGER does not 53 | center data when scaling, we will skip that step as well. 54 | 55 | `RunQuantileNorm` produces joint clusters, but users can also optionally 56 | perform Louvain community detection (`FindNeighbors` and `FindClusters`) 57 | on the integrated latent space from iNMF. 58 | 59 | ## 60 | 61 | ### Systematic comparative analysis of human PBMC 62 | 63 | To learn more about this dataset, type `?pbmcsca` 64 | 65 | ``` r 66 | InstallData("pbmcsca") 67 | data("pbmcsca") 68 | # Please update your `liger` version to 0.5.0 or above before following this tutorial 69 | pbmcsca <- NormalizeData(pbmcsca) 70 | pbmcsca <- FindVariableFeatures(pbmcsca) 71 | pbmcsca <- ScaleData(pbmcsca, split.by = "Method", do.center = FALSE) 72 | pbmcsca <- RunOptimizeALS(pbmcsca, k = 20, lambda = 5, split.by = "Method") 73 | pbmcsca <- RunQuantileNorm(pbmcsca, split.by = "Method") 74 | # You can optionally perform Louvain clustering (`FindNeighbors` and `FindClusters`) after 75 | # `RunQuantileNorm` according to your needs 76 | pbmcsca <- FindNeighbors(pbmcsca, reduction = "iNMF", dims = 1:20) 77 | pbmcsca <- FindClusters(pbmcsca, resolution = 0.3) 78 | # Dimensional reduction and plotting 79 | pbmcsca <- RunUMAP(pbmcsca, dims = 1:ncol(pbmcsca[["iNMF"]]), reduction = "iNMF") 80 | DimPlot(pbmcsca, group.by = c("Method", "ident", "CellType"), ncol = 3) 81 | ``` 82 | 83 | ![](/__w/seurat-wrappers/seurat-wrappers/test-build/liger_files/figure-gfm/pbmcsca-1.png) 84 | 85 | ### Interferon-stimulated and control PBMC 86 | 87 | To learn more about this dataset, type `?ifnb` 88 | 89 | ``` r 90 | InstallData("ifnb") 91 | data("ifnb") 92 | # Please update your `liger` version to 0.5.0 or above before following this tutorial. 93 | ifnb <- NormalizeData(ifnb) 94 | ifnb <- FindVariableFeatures(ifnb) 95 | ifnb <- ScaleData(ifnb, split.by = "stim", do.center = FALSE) 96 | ifnb <- RunOptimizeALS(ifnb, k = 20, lambda = 5, split.by = "stim") 97 | ifnb <- RunQuantileNorm(ifnb, split.by = "stim") 98 | # You can optionally perform Louvain clustering (`FindNeighbors` and `FindClusters`) after 99 | # `RunQuantileNorm` according to your needs 100 | ifnb <- FindNeighbors(ifnb, reduction = "iNMF", dims = 1:20) 101 | ifnb <- FindClusters(ifnb, resolution = 0.55) 102 | # Dimensional reduction and plotting 103 | ifnb <- RunUMAP(ifnb, dims = 1:ncol(ifnb[["iNMF"]]), reduction = "iNMF") 104 | DimPlot(ifnb, group.by = c("stim", "ident", "seurat_annotations"), ncol = 3) 105 | ``` 106 | 107 | ![](/__w/seurat-wrappers/seurat-wrappers/test-build/liger_files/figure-gfm/ifnb-1.png) 108 | 109 | ### Eight human pancreatic islet datasets 110 | 111 | To learn more about this dataset, type `?panc8` 112 | 113 | ``` r 114 | InstallData("panc8") 115 | data("panc8") 116 | # Please update your `liger` version to 0.5.0 or above before following this tutorial. 117 | panc8 <- NormalizeData(panc8) 118 | panc8 <- FindVariableFeatures(panc8) 119 | panc8 <- ScaleData(panc8, split.by = "replicate", do.center = FALSE) 120 | panc8 <- RunOptimizeALS(panc8, k = 20, lambda = 5, split.by = "replicate") 121 | panc8 <- RunQuantileNorm(panc8, split.by = "replicate") 122 | # You can optionally perform Louvain clustering (`FindNeighbors` and `FindClusters`) after 123 | # `RunQuantileNorm` according to your needs 124 | panc8 <- FindNeighbors(panc8, reduction = "iNMF", dims = 1:20) 125 | panc8 <- FindClusters(panc8, resolution = 0.4) 126 | # Dimensional reduction and plotting 127 | panc8 <- RunUMAP(panc8, dims = 1:ncol(panc8[["iNMF"]]), reduction = "iNMF") 128 | DimPlot(panc8, group.by = c("replicate", "ident", "celltype"), ncol = 3) 129 | ``` 130 | 131 | ![](/__w/seurat-wrappers/seurat-wrappers/test-build/liger_files/figure-gfm/pancreas-1.png) 132 | -------------------------------------------------------------------------------- /docs/liger_files/figure-gfm/ifnb-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/liger_files/figure-gfm/ifnb-1.png -------------------------------------------------------------------------------- /docs/liger_files/figure-gfm/pancreas-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/liger_files/figure-gfm/pancreas-1.png -------------------------------------------------------------------------------- /docs/liger_files/figure-gfm/pbmcsca-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/liger_files/figure-gfm/pbmcsca-1.png -------------------------------------------------------------------------------- /docs/miQC_files/figure-gfm/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/miQC_files/figure-gfm/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /docs/miQC_files/figure-gfm/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/miQC_files/figure-gfm/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /docs/miQC_files/figure-gfm/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/miQC_files/figure-gfm/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/miQC_files/figure-gfm/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/miQC_files/figure-gfm/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/miQC_files/figure-gfm/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/miQC_files/figure-gfm/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/miQC_files/figure-gfm/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/miQC_files/figure-gfm/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/miQC_files/figure-gfm/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/miQC_files/figure-gfm/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /docs/monocle3.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Calculating Trajectories with Monocle 3 and Seurat" 3 | output: 4 | html_document: 5 | df_print: kable 6 | theme: united 7 | github_document: 8 | html_preview: no 9 | toc: no 10 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 11 | --- 12 | 13 | This vigettte demonstrates how to run trajectory inference and pseudotime calculations with Monocle 3 on Seurat objects. If you use Monocle 3, please cite: 14 | 15 | > *The single-cell transcriptional landscape of mammalian organogenesis* 16 | > 17 | > Junyue Cao, Malte Spielmann, Xiaojie Qiu, Xingfan Huang, Daniel M. Ibrahim, Andrew J. Hill, Fan Zhang, Stefan Mundlos, Lena Christiansen, Frank J. Steemers, Cole Trapnell & Jay Shendure 18 | > 19 | > doi: [10.1038/s41586-019-0969-x](https://doi.org/10.1038/s41586-019-0969-x) 20 | > 21 | > Website: https://cole-trapnell-lab.github.io/monocle3/ 22 | 23 | ```{r setup, include=FALSE} 24 | knitr::opts_chunk$set( 25 | tidy = TRUE, 26 | tidy.opts = list(width.cutoff = 95), 27 | message = FALSE, 28 | warning = FALSE, 29 | fig.height = 10, 30 | fig.width = 16 31 | ) 32 | ``` 33 | 34 | Prerequisites to install: 35 | 36 | * [Seurat](https://satijalab.org/seurat/install) 37 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 38 | * [SeuratData](https://github.com/satijalab/seurat-data) 39 | * [Monocle 3](https://cole-trapnell-lab.github.io/monocle3/docs/installation/) 40 | 41 | ```{r install_deps, echo=FALSE, results="hide"} 42 | if (!requireNamespace("monocle3", quietly = TRUE)) { 43 | setRepositories(ind = 1:2) 44 | remotes::install_github( 45 | repo = "cole-trapnell-lab/monocle3", 46 | upgrade = FALSE 47 | ) 48 | } 49 | ``` 50 | 51 | ```{r packages} 52 | library(monocle3) 53 | library(Seurat) 54 | library(SeuratData) 55 | library(SeuratWrappers) 56 | library(ggplot2) 57 | library(patchwork) 58 | library(magrittr) 59 | ``` 60 | 61 | ## HCA Bone Marrow 40k 62 | 63 | ```{r load_hca, eval=FALSE} 64 | InstallData("hcabm40k") 65 | data("hcabm40k") 66 | ``` 67 | 68 | ```{r preprocess_hca, results='hide', eval=FALSE} 69 | hcabm40k <- SplitObject(hcabm40k, split.by = "orig.ident") 70 | for (i in seq_along(hcabm40k)) { 71 | hcabm40k[[i]] <- NormalizeData(hcabm40k[[i]]) %>% FindVariableFeatures() 72 | } 73 | features <- SelectIntegrationFeatures(hcabm40k) 74 | for (i in seq_along(along.with = hcabm40k)) { 75 | hcabm40k[[i]] <- ScaleData(hcabm40k[[i]], features = features) %>% 76 | RunPCA(features = features) 77 | } 78 | ``` 79 | 80 | ```{r integration, results='hide', eval=FALSE} 81 | anchors <- FindIntegrationAnchors( 82 | hcabm40k, 83 | reference = c(1, 2), 84 | reduction = "rpca", 85 | dims = 1:30 86 | ) 87 | integrated <- IntegrateData(anchors, dims = 1:30) 88 | ``` 89 | 90 | ```{r dimreduc_hca, results='hide', eval=FALSE} 91 | integrated <- ScaleData(integrated) 92 | integrated <- RunPCA(integrated) 93 | integrated <- RunUMAP(integrated, dims = 1:30, reduction.name = "UMAP") 94 | integrated <- FindNeighbors(integrated, dims = 1:30) 95 | integrated <- FindClusters(integrated) 96 | DimPlot(integrated, group.by = c("orig.ident", "ident")) 97 | ``` 98 | 99 | ```{r integrated_dimplot, echo=FALSE} 100 | con <- url("https://seurat.nygenome.org/monocle3/hcabm40k_integrated.Rds") 101 | integrated <- readRDS(file = con) 102 | close(con = con) 103 | DimPlot(object = integrated, group.by = c("orig.ident", "ident")) 104 | ``` 105 | 106 | ```{r monocle3_clustering, results='hide'} 107 | cds <- as.cell_data_set(integrated) 108 | cds <- cluster_cells(cds) 109 | p1 <- plot_cells(cds, show_trajectory_graph = FALSE) 110 | p2 <- plot_cells(cds, color_cells_by = "partition", show_trajectory_graph = FALSE) 111 | wrap_plots(p1, p2) 112 | ``` 113 | 114 | ```{r gc6, echo=FALSE, results="hide"} 115 | rm(integrated) 116 | gc(verbose = FALSE) 117 | ``` 118 | 119 | ```{r subset_partitions, results="hide"} 120 | integrated.sub <- subset(as.Seurat(cds), monocle3_partitions == 1) 121 | cds <- as.cell_data_set(integrated.sub) 122 | cds <- learn_graph(cds) 123 | plot_cells( 124 | cds, 125 | label_groups_by_cluster = FALSE, 126 | label_leaves = FALSE, 127 | label_branch_points = FALSE 128 | ) 129 | ``` 130 | 131 | ```{r gc7, echo=FALSE, results="hide"} 132 | gc(verbose = FALSE) 133 | ``` 134 | 135 | ```{r pseudotime, results="hide"} 136 | max.avp <- which.max(unlist(FetchData(integrated.sub, "AVP"))) 137 | max.avp <- colnames(integrated.sub)[max.avp] 138 | cds <- order_cells(cds, root_cells = max.avp) 139 | plot_cells( 140 | cds, 141 | color_cells_by = "pseudotime", 142 | label_cell_groups = FALSE, 143 | label_leaves = FALSE, 144 | label_branch_points = FALSE 145 | ) 146 | # Set the assay back as "integrated" 147 | integrated.sub <- as.Seurat(cds, assay = "integrated") 148 | FeaturePlot(integrated.sub, "monocle3_pseudotime") 149 | ``` 150 | -------------------------------------------------------------------------------- /docs/monocle3.md: -------------------------------------------------------------------------------- 1 | Calculating Trajectories with Monocle 3 and Seurat 2 | ================ 3 | Compiled: June 17, 2020 4 | 5 | This vigettte demonstrates how to run trajectory inference and 6 | pseudotime calculations with Monocle 3 on Seurat objects. If you use 7 | Monocle 3, please cite: 8 | 9 | > *The single-cell transcriptional landscape of mammalian organogenesis* 10 | > 11 | > Junyue Cao, Malte Spielmann, Xiaojie Qiu, Xingfan Huang, Daniel M. 12 | > Ibrahim, Andrew J. Hill, Fan Zhang, Stefan Mundlos, Lena Christiansen, 13 | > Frank J. Steemers, Cole Trapnell & Jay Shendure 14 | > 15 | > doi: 16 | > [10.1038/s41586-019-0969-x](https://doi.org/10.1038/s41586-019-0969-x) 17 | > 18 | > Website: 19 | 20 | Prerequisites to install: 21 | 22 | - [Seurat](https://satijalab.org/seurat/install) 23 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 24 | - [SeuratData](https://github.com/satijalab/seurat-data) 25 | - [Monocle 3](https://cole-trapnell-lab.github.io/monocle3/docs/installation/) 26 | 27 | 28 | 29 | ``` r 30 | library(monocle3) 31 | library(Seurat) 32 | library(SeuratData) 33 | library(SeuratWrappers) 34 | library(ggplot2) 35 | library(patchwork) 36 | library(magrittr) 37 | ``` 38 | 39 | ## HCA Bone Marrow 40k 40 | 41 | ``` r 42 | InstallData("hcabm40k") 43 | data("hcabm40k") 44 | ``` 45 | 46 | ``` r 47 | hcabm40k <- SplitObject(hcabm40k, split.by = "orig.ident") 48 | for (i in seq_along(hcabm40k)) { 49 | hcabm40k[[i]] <- NormalizeData(hcabm40k[[i]]) %>% FindVariableFeatures() 50 | } 51 | features <- SelectIntegrationFeatures(hcabm40k) 52 | for (i in seq_along(along.with = hcabm40k)) { 53 | hcabm40k[[i]] <- ScaleData(hcabm40k[[i]], features = features) %>% RunPCA(features = features) 54 | } 55 | ``` 56 | 57 | ``` r 58 | anchors <- FindIntegrationAnchors(hcabm40k, reference = c(1, 2), reduction = "rpca", dims = 1:30) 59 | integrated <- IntegrateData(anchors, dims = 1:30) 60 | ``` 61 | 62 | ``` r 63 | integrated <- ScaleData(integrated) 64 | integrated <- RunPCA(integrated) 65 | integrated <- RunUMAP(integrated, dims = 1:30, reduction.name = "UMAP") 66 | integrated <- FindNeighbors(integrated, dims = 1:30) 67 | integrated <- FindClusters(integrated) 68 | DimPlot(integrated, group.by = c("orig.ident", "ident")) 69 | ``` 70 | 71 | ![](monocle3_files/figure-gfm/integrated_dimplot-1.png) 72 | 73 | ``` r 74 | cds <- as.cell_data_set(integrated) 75 | cds <- cluster_cells(cds) 76 | p1 <- plot_cells(cds, show_trajectory_graph = FALSE) 77 | p2 <- plot_cells(cds, color_cells_by = "partition", show_trajectory_graph = FALSE) 78 | wrap_plots(p1, p2) 79 | ``` 80 | 81 | ![](monocle3_files/figure-gfm/monocle3_clustering-1.png) 82 | 83 | ``` r 84 | integrated.sub <- subset(as.Seurat(cds), monocle3_partitions == 1) 85 | cds <- as.cell_data_set(integrated.sub) 86 | cds <- learn_graph(cds) 87 | plot_cells(cds, label_groups_by_cluster = FALSE, label_leaves = FALSE, label_branch_points = FALSE) 88 | ``` 89 | 90 | ![](monocle3_files/figure-gfm/subset_partitions-1.png) 91 | 92 | ``` r 93 | max.avp <- which.max(unlist(FetchData(integrated.sub, "AVP"))) 94 | max.avp <- colnames(integrated.sub)[max.avp] 95 | cds <- order_cells(cds, root_cells = max.avp) 96 | plot_cells(cds, color_cells_by = "pseudotime", label_cell_groups = FALSE, label_leaves = FALSE, 97 | label_branch_points = FALSE) 98 | ``` 99 | 100 | ![](monocle3_files/figure-gfm/pseudotime-1.png) 101 | 102 | ``` r 103 | integrated.sub <- as.Seurat(cds) 104 | FeaturePlot(integrated.sub, "monocle3_pseudotime") 105 | ``` 106 | 107 | ![](monocle3_files/figure-gfm/pseudotime-2.png) 108 | -------------------------------------------------------------------------------- /docs/monocle3_files/figure-gfm/dimreduc_hca-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/monocle3_files/figure-gfm/dimreduc_hca-1.png -------------------------------------------------------------------------------- /docs/monocle3_files/figure-gfm/integrated_dimplot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/monocle3_files/figure-gfm/integrated_dimplot-1.png -------------------------------------------------------------------------------- /docs/monocle3_files/figure-gfm/monocle3_clustering-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/monocle3_files/figure-gfm/monocle3_clustering-1.png -------------------------------------------------------------------------------- /docs/monocle3_files/figure-gfm/pseudotime-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/monocle3_files/figure-gfm/pseudotime-1.png -------------------------------------------------------------------------------- /docs/monocle3_files/figure-gfm/pseudotime-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/monocle3_files/figure-gfm/pseudotime-2.png -------------------------------------------------------------------------------- /docs/monocle3_files/figure-gfm/subset_partitions-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/monocle3_files/figure-gfm/subset_partitions-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/cd4_and_clustering-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/cd4_and_clustering-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/cd4_comparison-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/cd4_comparison-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/cd4_comparison-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/cd4_comparison-2.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/plot_cd3d-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/plot_cd3d-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/plot_cd4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/plot_cd4-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/nebulosa_files/figure-gfm/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/nebulosa_files/figure-gfm/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/pacmap.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Running PaCMAP on a Seurat Object" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: false 7 | toc: false 8 | html_document: 9 | toc: false 10 | df_print: paged 11 | --- 12 | 13 | This vignette demonstrates how to run PaCMAP, a dimensionality reduction method that can 14 | be used for providing robust and trustworthy visualization, on a Seurat object. 15 | If you use our work, please cite both papers: 16 | 17 | > *Understanding How Dimension Reduction Tools Work: An Empirical Approach to Deciphering t-SNE, UMAP, TriMap, and PaCMAP for Data Visualization* 18 | > 19 | > Yingfan Wang, Haiyang Huang, Cynthia Rudin & Yaron Shaposhnik 20 | > 21 | > Journal of Machine Learning Research, 2021 22 | > 23 | > doi: https://doi.org/10.48550/arXiv.2012.04456 24 | > 25 | > *Towards a comprehensive evaluation of dimension reduction methods for transcriptomic data visualization* 26 | > 27 | > Haiyang Huang, Yingfan Wang, Cynthia Rudin and Edward P. Browne 28 | > 29 | > Communications biology, 2022 30 | > 31 | > doi: https://doi.org/10.1038/s42003-022-03628-x 32 | > 33 | > GitHub: https://github.com/YingfanWang/PaCMAP 34 | 35 | ```{r setup, include=FALSE} 36 | knitr::opts_chunk$set( 37 | message = FALSE, 38 | warning = FALSE, 39 | fig.width = 10 40 | ) 41 | ``` 42 | 43 | Prerequisites to install: 44 | 45 | * [Seurat](https://satijalab.org/seurat/install) 46 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 47 | * [SeuratData](https://github.com/satijalab/seurat-data) 48 | * [Reticulate](https://rstudio.github.io/reticulate/) 49 | 50 | In addition to R packages, PaCMAP relies on Python to deliver high performance. 51 | To streamline the installation process and make environment management easier, 52 | we strongly recommend you to use anaconda(https://www.anaconda.com/download) or 53 | miniconda(https://docs.anaconda.com/miniconda/miniconda-install/) for managing Python 54 | environments. Below, we provide step-by-step instructions on how to properly install PaCMAP 55 | **after** you have installed one of these tools. 56 | 57 | Create a conda environment with PaCMAP installed: 58 | 59 | ```{bash conda environment setup, eval=FALSE} 60 | conda create -n "pacmap" python=3.12 # Install in the environment called "pacmap" 61 | conda activate pacmap 62 | conda install -y conda-forge::pacmap 63 | ``` 64 | 65 | To run PaCMAP, you need to connect your R console to the corresponding conda environment. 66 | If your Conda/Miniconda installation is located in a non-default directory, you might 67 | set up the conda variable as `/path/to/your/conda`. This ensures the correct environment 68 | is used during the installation. 69 | 70 | ```{r conda environment connects, eval=FALSE} 71 | reticulate::use_condaenv(condaenv = "pacmap", conda = "auto") 72 | ``` 73 | 74 | ```{r packages} 75 | library(Seurat) 76 | library(SeuratData) 77 | library(SeuratWrappers) 78 | ``` 79 | 80 | ### PaCMAP on PBMC3k 81 | 82 | To learn more about this dataset, type `?pbmc3k` 83 | 84 | ```{r pacmap, cache=TRUE, cache.lazy=TRUE} 85 | InstallData("pbmc3k") 86 | pbmc3k.final <- LoadData("pbmc3k",type="pbmc3k.final") 87 | 88 | # Initial processing to select variable features 89 | pbmc3k.final <- UpdateSeuratObject(pbmc3k.final) 90 | pbmc3k.final <- FindVariableFeatures(pbmc3k.final) 91 | 92 | # run PaCMAP on Seurat object. 93 | pbmc3k.final <- RunPaCMAP(object = pbmc3k.final, features=VariableFeatures(pbmc3k.final)) 94 | ``` 95 | 96 | ```{r explore, fig.width=6} 97 | # visualize markers 98 | features.plot <- c('CD3D', 'MS4A1', 'CD8A', 'GZMK', 'GZMB', 'FCGR3A') 99 | DimPlot(object=pbmc3k.final,reduction="pacmap") 100 | ``` 101 | 102 | ```{r explore2, fig.height=10} 103 | pbmc3k.final <- NormalizeData(pbmc3k.final, verbose = FALSE) 104 | FeaturePlot(pbmc3k.final, features.plot, ncol = 2, reduction="pacmap") 105 | ``` 106 | You can also specify dims of your original dataset for running PaCMAP 107 | ```{r pacmap_dim, cache=TRUE, cache.lazy=TRUE} 108 | # run PaCMAP on Seurat object. 109 | pbmc3k.final <- RunPaCMAP(object = pbmc3k.final, dims=2:5) 110 | # visualize markers 111 | features.plot <- c('CD3D', 'MS4A1', 'CD8A', 'GZMK', 'GZMB', 'FCGR3A') 112 | DimPlot(object=pbmc3k.final,reduction="pacmap") 113 | ``` 114 | -------------------------------------------------------------------------------- /docs/pacmap_files/figure-gfm/explore-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/pacmap_files/figure-gfm/explore-1.png -------------------------------------------------------------------------------- /docs/pacmap_files/figure-gfm/explore2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/pacmap_files/figure-gfm/explore2-1.png -------------------------------------------------------------------------------- /docs/pacmap_files/figure-gfm/pacmap_dim-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/pacmap_files/figure-gfm/pacmap_dim-1.png -------------------------------------------------------------------------------- /docs/pacmap_files/figure-html/explore-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/pacmap_files/figure-html/explore-1.png -------------------------------------------------------------------------------- /docs/pacmap_files/figure-html/explore2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/pacmap_files/figure-html/explore2-1.png -------------------------------------------------------------------------------- /docs/pacmap_files/figure-html/pacmap_dim-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/pacmap_files/figure-html/pacmap_dim-1.png -------------------------------------------------------------------------------- /docs/presto.md: -------------------------------------------------------------------------------- 1 | Fast Differential Expression with Presto 2 | ================ 3 | Compiled: October 07, 2020 4 | 5 | This vignette demonstrates the use of the Presto package in Seurat. 6 | Commands and parameters are based off of the [Presto 7 | tutorial](http://htmlpreview.github.io/?https://github.com/immunogenomics/presto/blob/master/docs/getting-started.html). 8 | If you use Presto in your work, please cite: 9 | 10 | > *Presto scales Wilcoxon and auROC analyses to millions of 11 | > observations* 12 | > 13 | > Ilya Korsunsky, Aparna Nathan, Nghia Millard, Soumya Raychaudhuri 14 | > 15 | > bioRxiv, 2019. 16 | > 17 | > Pre-print: 18 | > 19 | > GitHub: 20 | 21 | Prerequisites to install: 22 | 23 | - [Seurat](https://satijalab.org/seurat/install) 24 | - [Presto](https://github.com/immunogenomics/presto) 25 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 26 | - [SeuratData](https://github.com/satijalab/seurat-data) 27 | 28 | 29 | 30 | ``` r 31 | library(presto) 32 | library(Seurat) 33 | library(SeuratData) 34 | library(SeuratWrappers) 35 | ``` 36 | 37 | ### Differential Expression Testing for PBMC scRNA-seq Data 38 | 39 | To learn more about this dataset, type `?pbmc3k` 40 | 41 | ``` r 42 | InstallData("pbmc3k") 43 | data("pbmc3k") 44 | pbmc3k <- NormalizeData(pbmc3k) 45 | Idents(pbmc3k) <- "seurat_annotations" 46 | 47 | diffexp.B.Mono <- RunPresto(pbmc3k, "CD14+ Mono", "B") 48 | head(diffexp.B.Mono, 10) 49 | ``` 50 | 51 | ## p_val avg_logFC pct.1 pct.2 p_val_adj 52 | ## CD79A 1.660326e-143 -2.989854 0.042 0.936 2.276972e-139 53 | ## TYROBP 3.516407e-138 3.512505 0.994 0.102 4.822401e-134 54 | ## S100A9 7.003189e-137 4.293303 0.996 0.134 9.604174e-133 55 | ## CST3 1.498348e-135 3.344758 0.992 0.174 2.054834e-131 56 | ## S100A4 8.872946e-135 2.854897 1.000 0.360 1.216836e-130 57 | ## LYZ 2.720838e-134 3.788514 1.000 0.422 3.731357e-130 58 | ## S100A8 3.115452e-133 4.039777 0.975 0.076 4.272530e-129 59 | ## CD79B 8.317731e-133 -2.667534 0.083 0.916 1.140694e-128 60 | ## S100A6 5.156920e-132 2.541609 0.996 0.352 7.072201e-128 61 | ## LGALS1 1.427548e-131 3.002493 0.979 0.131 1.957739e-127 62 | 63 | ``` r 64 | diffexp.all <- RunPrestoAll(pbmc3k) 65 | head(diffexp.all[diffexp.all$cluster == "B", ], 10) 66 | ``` 67 | 68 | ## p_val avg_logFC pct.1 pct.2 p_val_adj cluster gene 69 | ## CD79A.3 0.000000e+00 2.933865 0.936 0.044 0.000000e+00 B CD79A 70 | ## MS4A1.3 0.000000e+00 2.290577 0.855 0.055 0.000000e+00 B MS4A1 71 | ## LINC00926.1 2.998236e-274 1.956493 0.564 0.010 4.111781e-270 B LINC00926 72 | ## CD79B.3 1.126919e-273 2.381160 0.916 0.144 1.545457e-269 B CD79B 73 | ## TCL1A.3 1.962618e-272 2.463556 0.622 0.023 2.691534e-268 B TCL1A 74 | ## HLA-DQA1.2 3.017803e-267 2.104207 0.890 0.119 4.138616e-263 B HLA-DQA1 75 | ## VPREB3 2.131575e-238 1.667466 0.488 0.008 2.923242e-234 B VPREB3 76 | ## HLA-DQB1.2 2.076231e-230 2.112052 0.863 0.148 2.847343e-226 B HLA-DQB1 77 | ## CD74.2 1.000691e-184 2.010688 1.000 0.819 1.372347e-180 B CD74 78 | ## HLA-DRA.3 1.813356e-184 1.914531 1.000 0.492 2.486837e-180 B HLA-DRA 79 | -------------------------------------------------------------------------------- /docs/presto.rmd: -------------------------------------------------------------------------------- 1 | 2 | 3 | --- 4 | title: "Fast Differential Expression with Presto" 5 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 6 | output: 7 | github_document: 8 | html_preview: true 9 | toc: true 10 | toc_depth: 3 11 | fig_width: 16 12 | html_document: 13 | df_print: kable 14 | theme: united 15 | fig_height: 5 16 | fig_width: 16 17 | out_height: 4 18 | --- 19 | 20 | This vignette demonstrates the use of the Presto package in Seurat. Commands and parameters are based off of the [Presto tutorial](http://htmlpreview.github.io/?https://github.com/immunogenomics/presto/blob/master/docs/getting-started.html). If you use Presto in your work, please cite: 21 | 22 | > *Presto scales Wilcoxon and auROC analyses to millions of observations* 23 | > 24 | > Ilya Korsunsky, Aparna Nathan, Nghia Millard, Soumya Raychaudhuri 25 | > 26 | > bioRxiv, 2019. 27 | > 28 | > Pre-print: https://www.biorxiv.org/content/10.1101/653253v1.full.pdf 29 | > 30 | > GitHub: https://github.com/immunogenomics/presto 31 | 32 | ```{r setup, include=FALSE} 33 | if (!requireNamespace("presto")) { 34 | remotes::install_github("immunogenomics/presto", upgrade = FALSE) 35 | } 36 | knitr::opts_chunk$set( 37 | tidy = TRUE, 38 | tidy.opts = list(width.cutoff = 95), 39 | message = FALSE, 40 | warning = FALSE 41 | ) 42 | ``` 43 | 44 | Prerequisites to install: 45 | 46 | * [Seurat](https://satijalab.org/seurat/install) 47 | * [Presto](https://github.com/immunogenomics/presto) 48 | * [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 49 | * [SeuratData](https://github.com/satijalab/seurat-data) 50 | 51 | ```{r packages} 52 | library(presto) 53 | library(Seurat) 54 | library(SeuratData) 55 | library(SeuratWrappers) 56 | ``` 57 | 58 | ### Differential Expression Testing for PBMC scRNA-seq Data 59 | 60 | To learn more about this dataset, type `?pbmc3k` 61 | 62 | ```{r pbmc3k, cache=TRUE} 63 | InstallData("pbmc3k") 64 | data("pbmc3k") 65 | pbmc3k <- NormalizeData(pbmc3k) 66 | Idents(pbmc3k) <- 'seurat_annotations' 67 | 68 | diffexp.B.Mono <- RunPresto(pbmc3k, 'CD14+ Mono', 'B') 69 | head(diffexp.B.Mono, 10) 70 | 71 | diffexp.all <- RunPrestoAll(pbmc3k) 72 | head(diffexp.all[diffexp.all$cluster=='B', ], 10) 73 | ``` 74 | 75 | -------------------------------------------------------------------------------- /docs/schex_files/figure-markdown_github/plot-density-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/schex_files/figure-markdown_github/plot-density-1.png -------------------------------------------------------------------------------- /docs/schex_files/figure-markdown_github/plot-gene-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/schex_files/figure-markdown_github/plot-gene-1.png -------------------------------------------------------------------------------- /docs/schex_files/figure-markdown_github/plot-meta-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/schex_files/figure-markdown_github/plot-meta-1-1.png -------------------------------------------------------------------------------- /docs/schex_files/figure-markdown_github/plot-meta-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/schex_files/figure-markdown_github/plot-meta-2-1.png -------------------------------------------------------------------------------- /docs/schex_files/figure-markdown_github/plot-meta-label-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/schex_files/figure-markdown_github/plot-meta-label-1.png -------------------------------------------------------------------------------- /docs/scvelo.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Estimating RNA Velocity using Seurat and scVelo" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | html_document: 6 | df_print: kable 7 | theme: united 8 | github_document: 9 | html_preview: true 10 | toc: false 11 | --- 12 | 13 | This vignette demonstrates analysing RNA Velocity quantifications stored in a Seurat object using scVelo. If you use scVelo in your work, please cite: 14 | 15 | > *Generalizing RNA velocity to transient cell states through dynamical modeling* 16 | > 17 | > Volker Bergen, Marius Lange, Stefan Peidli, F. Alexander Wolf & Fabian J. Theis 18 | > 19 | > doi: [10.1101/820936](https://doi.org/10.1101/820936) 20 | > 21 | > Website: https://scvelo.readthedocs.io/ 22 | 23 | ```{r setup, include=FALSE} 24 | python3 <- Sys.which(names = c("python3.6", "python3")) 25 | python3 <- unname(obj = Filter(f = nchar, x = python3))[1] 26 | library(reticulate) 27 | reticulate::use_python(python = python3, required = TRUE) 28 | knitr::opts_chunk$set( 29 | tidy = TRUE, 30 | tidy.opts = list(width.cutoff = 95), 31 | message = FALSE, 32 | warning = FALSE, 33 | fig.height = 10, 34 | fig.width = 16 35 | ) 36 | ``` 37 | 38 | ```{r install_deps, echo=FALSE} 39 | if (!requireNamespace("SeuratDisk", quietly = TRUE)) { 40 | remotes::install_github(repo = "mojaveazure/seurat-disk", upgrade = FALSE) 41 | } 42 | if (!py_module_available(module = "scvelo")) { 43 | pip3 <- Sys.which(names = "pip3")[1] 44 | if (!nchar(x = pip3)) { 45 | stop("Cannot find pip3 or scvelo", call. = FALSE) 46 | } 47 | system2(command = pip3, args = c("install", "scvelo")) 48 | } 49 | ``` 50 | 51 | Prerequisites to install: 52 | 53 | - [Seurat](https://satijalab.org/seurat/install) 54 | - [scVelo](https://scvelo.readthedocs.io/installation.html) 55 | - [SeuratDisk](https://mojaveazure.github.io/seurat-disk/#installation) 56 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 57 | 58 | ```{r packages} 59 | library(Seurat) 60 | library(SeuratDisk) 61 | library(SeuratWrappers) 62 | ``` 63 | 64 | ```{r cleanup, results="hide", echo=FALSE, eval=TRUE} 65 | if (file.exists("mouseBM.h5Seurat")) { 66 | file.remove("mouseBM.h5Seurat") 67 | } 68 | if (file.exists("mouseBM.h5ad")) { 69 | file.remove("mouseBM.h5ad") 70 | } 71 | ``` 72 | 73 | ```{r download, results="hide", echo=FALSE, eval=TRUE} 74 | dir.create("~/Downloads", showWarnings = FALSE, recursive = TRUE) 75 | curl::curl_download( 76 | url = "http://pklab.med.harvard.edu/velocyto/mouseBM/SCG71.loom", 77 | destfile = "~/Downloads/SCG71.loom" 78 | ) 79 | ``` 80 | 81 | ```{r load_data3, results='hide', eval=TRUE} 82 | # If you don't have velocyto's example mouse bone marrow dataset, download with the CURL command 83 | # curl::curl_download(url = "http://pklab.med.harvard.edu/velocyto/mouseBM/SCG71.loom", destfile = "~/Downloads/SCG71.loom") 84 | ldat <- ReadVelocity(file = "~/Downloads/SCG71.loom") 85 | bm <- as.Seurat(x = ldat) 86 | bm[["RNA"]] <- bm[["spliced"]] 87 | bm <- SCTransform(bm) 88 | bm <- RunPCA(bm) 89 | bm <- RunUMAP(bm, dims = 1:20) 90 | bm <- FindNeighbors(bm, dims = 1:20) 91 | bm <- FindClusters(bm) 92 | DefaultAssay(bm) <- "RNA" 93 | SaveH5Seurat(bm, filename = "mouseBM.h5Seurat") 94 | Convert("mouseBM.h5Seurat", dest = "h5ad") 95 | ``` 96 | 97 | ```{python load_adata, eval=TRUE} 98 | # In Python 99 | import scvelo as scv 100 | adata = scv.read("mouseBM.h5ad") 101 | adata 102 | ``` 103 | 104 | ```{python scvelo, results="hide", eval=TRUE} 105 | scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000) 106 | scv.pp.moments(adata, n_pcs=30, n_neighbors=30) 107 | scv.tl.velocity(adata) 108 | scv.tl.velocity_graph(adata) 109 | scv.pl.velocity_embedding_stream(adata, basis="umap", color="seurat_clusters") 110 | scv.pl.velocity_embedding(adata, basis="umap", color="seurat_clusters", arrow_length=3, arrow_size=2, dpi=120) 111 | ``` 112 | 113 | ```{python latent_time, results="hide", eval=TRUE} 114 | scv.tl.recover_dynamics(adata) 115 | scv.tl.latent_time(adata) 116 | scv.pl.scatter(adata, color="latent_time", color_map="gnuplot") 117 | top_genes = adata.var["fit_likelihood"].sort_values(ascending=False).index[:300] 118 | scv.pl.heatmap(adata, var_names=top_genes, sortby="latent_time", col_color="seurat_clusters", n_convolve=100) 119 | ``` 120 | -------------------------------------------------------------------------------- /docs/scvelo.md: -------------------------------------------------------------------------------- 1 | Estimating RNA Velocity using Seurat and scVelo 2 | ================ 3 | Compiled: June 10, 2020 4 | 5 | This vignette demonstrates analysing RNA Velocity quantifications stored 6 | in a Seurat object using scVelo. If you use scVelo in your work, please 7 | cite: 8 | 9 | > *Generalizing RNA velocity to transient cell states through dynamical 10 | > modeling* 11 | > 12 | > Volker Bergen, Marius Lange, Stefan Peidli, F. Alexander Wolf & Fabian 13 | > J. Theis 14 | > 15 | > doi: [10.1101/820936](https://doi.org/10.1101/820936) 16 | > 17 | > Website: 18 | 19 | Prerequisites to 20 | install: 21 | 22 | - [Seurat](https://satijalab.org/seurat/install) 23 | - [scVelo](https://scvelo.readthedocs.io/installation.html) 24 | - [SeuratDisk](https://mojaveazure.github.io/seurat-disk/#installation) 25 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 26 | 27 | 28 | 29 | ``` r 30 | library(Seurat) 31 | library(SeuratDisk) 32 | library(SeuratWrappers) 33 | ``` 34 | 35 | ``` r 36 | # If you don't have velocyto's example mouse bone marrow dataset, download with the CURL command 37 | # curl::curl_download(url = 'http://pklab.med.harvard.edu/velocyto/mouseBM/SCG71.loom', destfile 38 | # = '~/Downloads/SCG71.loom') 39 | ldat <- ReadVelocity(file = "~/Downloads/SCG71.loom") 40 | bm <- as.Seurat(x = ldat) 41 | bm[["RNA"]] <- bm[["spliced"]] 42 | bm <- SCTransform(bm) 43 | bm <- RunPCA(bm) 44 | bm <- RunUMAP(bm, dims = 1:20) 45 | bm <- FindNeighbors(bm, dims = 1:20) 46 | bm <- FindClusters(bm) 47 | DefaultAssay(bm) <- "RNA" 48 | SaveH5Seurat(bm, filename = "mouseBM.h5Seurat") 49 | Convert("mouseBM.h5Seurat", dest = "h5ad") 50 | ``` 51 | 52 | ``` python 53 | # In Python 54 | import scvelo as scv 55 | adata = scv.read("mouseBM.h5ad") 56 | adata 57 | ``` 58 | 59 | ## AnnData object with n_obs × n_vars = 6667 × 24421 60 | ## obs: 'orig.ident', 'nCount_spliced', 'nFeature_spliced', 'nCount_unspliced', 'nFeature_unspliced', 'nCount_ambiguous', 'nFeature_ambiguous', 'nCount_RNA', 'nFeature_RNA', 'nCount_SCT', 'nFeature_SCT', 'SCT_snn_res.0.8', 'seurat_clusters' 61 | ## var: 'features', 'ambiguous_features', 'spliced_features', 'unspliced_features' 62 | ## obsm: 'X_umap' 63 | ## layers: 'ambiguous', 'spliced', 'unspliced' 64 | 65 | ``` python 66 | scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000) 67 | ``` 68 | 69 | ``` python 70 | scv.pp.moments(adata, n_pcs=30, n_neighbors=30) 71 | ``` 72 | 73 | ``` python 74 | scv.tl.velocity(adata) 75 | ``` 76 | 77 | ``` python 78 | scv.tl.velocity_graph(adata) 79 | ``` 80 | 81 | ``` python 82 | scv.pl.velocity_embedding_stream(adata, basis="umap", color="seurat_clusters") 83 | ``` 84 | 85 | 86 | 87 | ``` python 88 | scv.pl.velocity_embedding(adata, basis="umap", color="seurat_clusters", arrow_length=3, arrow_size=2, dpi=120) 89 | ``` 90 | 91 | 92 | 93 | ``` python 94 | scv.tl.recover_dynamics(adata) 95 | ``` 96 | 97 | ``` python 98 | scv.tl.latent_time(adata) 99 | ``` 100 | 101 | ``` python 102 | scv.pl.scatter(adata, color="latent_time", color_map="gnuplot") 103 | ``` 104 | 105 | 106 | 107 | ``` python 108 | top_genes = adata.var["fit_likelihood"].sort_values(ascending=False).index[:300] 109 | scv.pl.heatmap(adata, var_names=top_genes, sortby="latent_time", col_color="seurat_clusters", n_convolve=100) 110 | ``` 111 | 112 | 113 | -------------------------------------------------------------------------------- /docs/scvelo_files/figure-gfm/adata_plot_test-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-gfm/adata_plot_test-1.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-gfm/latent_time-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-gfm/latent_time-1.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-gfm/latent_time-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-gfm/latent_time-2.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-gfm/matplotlib_test-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-gfm/matplotlib_test-1.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-gfm/scvelo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-gfm/scvelo-1.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-gfm/scvelo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-gfm/scvelo-2.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-html/latent_time-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-html/latent_time-1.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-html/latent_time-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-html/latent_time-2.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-html/scvelo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-html/scvelo-1.png -------------------------------------------------------------------------------- /docs/scvelo_files/figure-html/scvelo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/scvelo_files/figure-html/scvelo-2.png -------------------------------------------------------------------------------- /docs/tricycle_files/figure-gfm/density-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/tricycle_files/figure-gfm/density-1.png -------------------------------------------------------------------------------- /docs/tricycle_files/figure-gfm/density-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/tricycle_files/figure-gfm/density-2.png -------------------------------------------------------------------------------- /docs/tricycle_files/figure-gfm/loess-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/tricycle_files/figure-gfm/loess-1.png -------------------------------------------------------------------------------- /docs/tricycle_files/figure-gfm/plotemb-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/tricycle_files/figure-gfm/plotemb-1.png -------------------------------------------------------------------------------- /docs/velocity.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Estimating RNA Velocity using Seurat" 3 | date: 'Compiled: `r format(Sys.Date(), "%B %d, %Y")`' 4 | output: 5 | github_document: 6 | html_preview: true 7 | toc: false 8 | html_document: 9 | df_print: kable 10 | theme: united 11 | --- 12 | 13 | This vignette demonstrates analysing RNA Velocity quantifications stored in a Seurat object. Parameters are based off of the [RNA Velocity tutorial](http://pklab.med.harvard.edu/velocyto/notebooks/R/SCG71.nb.html). If you use velocyto in your work, please cite: 14 | 15 | > *RNA velocity of single cells* 16 | > 17 | > Gioele La Manno, Ruslan Soldatov, Amit Zeisel, Emelie Braun, Hannah Hochgerner, Viktor Petukhov, Katja Lidschreiber, Maria E. Kastriti, Peter Lönnerberg, Alessandro Furlan, Jean Fan, Lars E. Borm, Zehua Liu, David van Bruggen, Jimin Guo, Xiaoling He, Roger Barker, Erik Sundström, Gonçalo Castelo-Branco, Patrick Cramer, Igor Adameyko, Sten Linnarsson & Peter V. Kharchenko 18 | > 19 | > doi: [10.1038/s41586-018-0414-6](https://doi.org/10.1038/s41586-018-0414-6) 20 | > 21 | > Website: https://velocyto.org 22 | 23 | ```{r setup, include=FALSE} 24 | knitr::opts_chunk$set( 25 | tidy = TRUE, 26 | tidy.opts = list(width.cutoff = 95), 27 | message = FALSE, 28 | warning = FALSE, 29 | fig.height = 10, 30 | fig.width = 16 31 | ) 32 | ``` 33 | 34 | Prerequisites to install: 35 | 36 | - [Seurat](https://satijalab.org/seurat/install) 37 | - [velocyto.R](https://github.com/velocyto-team/velocyto.R) 38 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 39 | 40 | ```{r packages} 41 | library(Seurat) 42 | library(velocyto.R) 43 | library(SeuratWrappers) 44 | ``` 45 | 46 | ```{r load_data, results='hide', cache=TRUE} 47 | # If you don't have velocyto's example mouse bone marrow dataset, download with the CURL command 48 | # curl::curl_download(url = "http://pklab.med.harvard.edu/velocyto/mouseBM/SCG71.loom", destfile = '~/Downloads/SCG71.loom') 49 | ldat <- ReadVelocity(file = '~/Downloads/SCG71.loom') 50 | bm <- as.Seurat(x = ldat) 51 | bm <- SCTransform(object = bm, assay = 'spliced') 52 | bm <- RunPCA(object = bm, verbose = FALSE) 53 | bm <- FindNeighbors(object = bm, dims = 1:20) 54 | bm <- FindClusters(object = bm) 55 | bm <- RunUMAP(object = bm, dims = 1:20) 56 | bm <- RunVelocity( 57 | object = bm, 58 | deltaT = 1, 59 | kCells = 25, 60 | fit.quantile = 0.02 61 | ) 62 | ident.colors <- scales::hue_pal()(n = length(x = levels(x = bm))) 63 | names(x = ident.colors) <- levels(x = bm) 64 | cell.colors <- ident.colors[Idents(object = bm)] 65 | names(x = cell.colors) <- colnames(x = bm) 66 | show.velocity.on.embedding.cor( 67 | emb = Embeddings(object = bm, reduction = 'umap'), 68 | vel = Tool(object = bm, slot = 'RunVelocity'), 69 | n = 200, 70 | scale = 'sqrt', 71 | cell.colors = ac(x = cell.colors, alpha = 0.5), 72 | cex = 0.8, 73 | arrow.scale = 3, 74 | show.grid.flow = TRUE, 75 | min.grid.cell.mass = 0.5, 76 | grid.n = 40, 77 | arrow.lwd = 1, 78 | do.par = FALSE, 79 | cell.border.alpha = 0.1 80 | ) 81 | ``` 82 | -------------------------------------------------------------------------------- /docs/velocity.md: -------------------------------------------------------------------------------- 1 | Estimating RNA Velocity using Seurat 2 | ================ 3 | Compiled: July 15, 2019 4 | 5 | This vignette demonstrates analysing RNA Velocity quantifications stored in a Seurat object. Parameters are based off of the [RNA Velocity tutorial](http://pklab.med.harvard.edu/velocyto/notebooks/R/SCG71.nb.html). If you use velocyto in your work, please cite: 6 | 7 | > *RNA velocity of single cells* 8 | > 9 | > Gioele La Manno, Ruslan Soldatov, Amit Zeisel, Emelie Braun, Hannah Hochgerner, Viktor Petukhov, Katja Lidschreiber, Maria E. Kastriti, Peter Lönnerberg, Alessandro Furlan, Jean Fan, Lars E. Borm, Zehua Liu, David van Bruggen, Jimin Guo, Xiaoling He, Roger Barker, Erik Sundström, Gonçalo Castelo-Branco, Patrick Cramer, Igor Adameyko, Sten Linnarsson & Peter V. Kharchenko 10 | > 11 | > doi: [10.1038/s41586-018-0414-6](https://doi.org/10.1038/s41586-018-0414-6) 12 | > 13 | > Website: 14 | 15 | Prerequisites to install: 16 | 17 | - [Seurat](https://satijalab.org/seurat/install) 18 | - [velocyto.R](https://github.com/velocyto-team/velocyto.R) 19 | - [SeuratWrappers](https://github.com/satijalab/seurat-wrappers) 20 | 21 | ``` r 22 | library(Seurat) 23 | library(velocyto.R) 24 | library(SeuratWrappers) 25 | ``` 26 | 27 | ``` r 28 | # If you don't have velocyto's example mouse bone marrow dataset, download with the CURL command 29 | # curl::curl_download(url = 'http://pklab.med.harvard.edu/velocyto/mouseBM/SCG71.loom', destfile 30 | # = '~/Downloads/SCG71.loom') 31 | ldat <- ReadVelocity(file = "~/Downloads/SCG71.loom") 32 | bm <- as.Seurat(x = ldat) 33 | bm <- SCTransform(object = bm, assay = "spliced") 34 | bm <- RunPCA(object = bm, verbose = FALSE) 35 | bm <- FindNeighbors(object = bm, dims = 1:20) 36 | bm <- FindClusters(object = bm) 37 | bm <- RunUMAP(object = bm, dims = 1:20) 38 | bm <- RunVelocity(object = bm, deltaT = 1, kCells = 25, fit.quantile = 0.02) 39 | ident.colors <- (scales::hue_pal())(n = length(x = levels(x = bm))) 40 | names(x = ident.colors) <- levels(x = bm) 41 | cell.colors <- ident.colors[Idents(object = bm)] 42 | names(x = cell.colors) <- colnames(x = bm) 43 | show.velocity.on.embedding.cor(emb = Embeddings(object = bm, reduction = "umap"), vel = Tool(object = bm, 44 | slot = "RunVelocity"), n = 200, scale = "sqrt", cell.colors = ac(x = cell.colors, alpha = 0.5), 45 | cex = 0.8, arrow.scale = 3, show.grid.flow = TRUE, min.grid.cell.mass = 0.5, grid.n = 40, arrow.lwd = 1, 46 | do.par = FALSE, cell.border.alpha = 0.1) 47 | ``` 48 | 49 | ![](velocity_files/figure-markdown_github/load_data-1.png) 50 | -------------------------------------------------------------------------------- /docs/velocity_files/figure-markdown_github/load_data-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satijalab/seurat-wrappers/a1eb0d8b039ad6d5ef0ff1332fd8eb1c0c223553/docs/velocity_files/figure-markdown_github/load_data-1.png -------------------------------------------------------------------------------- /man/ALRAChooseKPlot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/alra.R 3 | \name{ALRAChooseKPlot} 4 | \alias{ALRAChooseKPlot} 5 | \title{ALRA Approximate Rank Selection Plot} 6 | \usage{ 7 | ALRAChooseKPlot(object, start = 0, combine = TRUE) 8 | } 9 | \arguments{ 10 | \item{object}{Seurat object} 11 | 12 | \item{start}{Index to start plotting singular value spacings from. 13 | The transition from "signal" to "noise" in the is hard to see because the 14 | first singular value spacings are so large. Nicer visualizations result from 15 | skipping the first few. If set to 0 (default) starts from k/2.} 16 | 17 | \item{combine}{Combine plots into a single gg object; note that if TRUE, 18 | themeing will not work when plotting multiple features} 19 | } 20 | \value{ 21 | A list of 3 ggplot objects splotting the singular values, the 22 | spacings of the singular values, and the p-values of the singular values. 23 | } 24 | \description{ 25 | Plots the results of the approximate rank selection process for ALRA. 26 | } 27 | \seealso{ 28 | \code{\link{RunALRA}} 29 | } 30 | \author{ 31 | Jun Zhao, George Linderman 32 | } 33 | -------------------------------------------------------------------------------- /man/CellBrowser.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cellbrowser.R 3 | \name{CellBrowser} 4 | \alias{CellBrowser} 5 | \alias{ExportToCellbrowser} 6 | \title{Export \code{Seurat} objects for UCSC cell browser and stop open cell browser 7 | instances from R} 8 | \usage{ 9 | ExportToCellbrowser( 10 | object, 11 | dir, 12 | dataset.name = Project(object = object), 13 | reductions = NULL, 14 | markers.file = NULL, 15 | cluster.field = NULL, 16 | cb.dir = NULL, 17 | port = NULL, 18 | use.mtx = FALSE, 19 | meta.fields = NULL, 20 | meta.fields.names = NULL, 21 | matrix.slot = "counts", 22 | markers.n = 100, 23 | skip.markers = FALSE, 24 | skip.expr.matrix = FALSE, 25 | skip.metadata = FALSE, 26 | skip.reductions = FALSE 27 | ) 28 | } 29 | \arguments{ 30 | \item{object}{Seurat object} 31 | 32 | \item{dir}{path to directory where to save exported files. These are: 33 | exprMatrix.tsv, tsne.coords.tsv, meta.tsv, markers.tsv and a default 34 | cellbrowser.conf} 35 | 36 | \item{dataset.name}{name of the dataset. Defaults to Seurat project name} 37 | 38 | \item{reductions}{vector of reduction names to export, defaults to all reductions.} 39 | 40 | \item{markers.file}{path to file with marker genes. By defaults, marker 41 | are searched in the object itself as misc$markers. If none are supplied in 42 | object or via this argument, they are recalculated with \code{FindAllMarkers}} 43 | 44 | \item{cluster.field}{name of the metadata field containing cell cluster} 45 | 46 | \item{cb.dir}{path to directory where to create UCSC cellbrowser static 47 | website content root, e.g. an index.html, .json files, etc. These files 48 | can be copied to any webserver. If this is specified, the cellbrowser 49 | package has to be accessible from R via reticulate.} 50 | 51 | \item{port}{on which port to run UCSC cellbrowser webserver after export} 52 | 53 | \item{use.mtx}{export the matrix in .mtx.gz format. Default is False, 54 | unless the matrix is bigger than R's maximum matrix size.} 55 | 56 | \item{meta.fields}{vector of meta fields to export, default is all.} 57 | 58 | \item{meta.fields.names}{vector meta field names to show in UI. Must have 59 | same length as meta.fields. Default is meta.fields.} 60 | 61 | \item{matrix.slot}{matrix to use, default is 'counts'} 62 | 63 | \item{markers.n}{if no markers were supplied, FindAllMarkers is run. 64 | This parameter indicates how many markers to calculate, default is 100} 65 | 66 | \item{skip.markers}{whether to skip exporting markers} 67 | 68 | \item{skip.expr.matrix}{whether to skip exporting expression matrix} 69 | 70 | \item{skip.metadata}{whether to skip exporting metadata} 71 | 72 | \item{skip.reductions}{whether to skip exporting reductions} 73 | 74 | \item{...}{specifies the metadata fields to export. To supply a field and its 75 | human readable name, pass name as \code{field="name"} parameter.} 76 | } 77 | \value{ 78 | This function exports Seurat object as a set of tsv files 79 | to \code{dir} directory, copying the \code{markers.file} if it is 80 | passed. It also creates the default \code{cellbrowser.conf} in the 81 | directory. This directory could be read by \code{cbBuild} to 82 | create a static website viewer for the dataset. If \code{cb.dir} 83 | parameter is passed, the function runs \code{cbBuild} (if it is 84 | installed) to create this static website in \code{cb.dir} directory. 85 | If \code{port} parameter is passed, it also runs the webserver for 86 | that directory and opens a browser. 87 | } 88 | \description{ 89 | Export \code{Seurat} objects for UCSC cell browser and stop open cell browser 90 | instances from R 91 | } 92 | \examples{ 93 | \dontrun{ 94 | ExportToCellbrowser(pbmc_small, dataset.name = "PBMC", dir = "out") 95 | } 96 | 97 | } 98 | \author{ 99 | Maximilian Haeussler, Nikolay Markov 100 | } 101 | -------------------------------------------------------------------------------- /man/FastMNNIntegration.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fast_mnn_v5.R 3 | \name{FastMNNIntegration} 4 | \alias{FastMNNIntegration} 5 | \title{Run fastMNN in Seurat 5} 6 | \usage{ 7 | FastMNNIntegration( 8 | object, 9 | assay = NULL, 10 | orig = NULL, 11 | groups = NULL, 12 | layers = NULL, 13 | scale.layer = NULL, 14 | features = 2000, 15 | new.reduction = "integrated.mnn", 16 | reduction.key = "mnn_", 17 | reconstructed.assay = "mnn.reconstructed", 18 | verbose = TRUE, 19 | ... 20 | ) 21 | } 22 | \arguments{ 23 | \item{object}{A merged seurat object} 24 | 25 | \item{assay}{Assay to use, defaults to the default assay of the first object} 26 | 27 | \item{groups}{A one-column data frame with grouping information} 28 | 29 | \item{layers}{Layers to use} 30 | 31 | \item{features}{Either a list of features to use when calculating batch 32 | correction, or a number (2000 by default) of variable features to select.} 33 | 34 | \item{reduction.key}{Key for resulting DimReduc} 35 | 36 | \item{reconstructed.assay}{Name for the assay containing the low-rank 37 | reconstruction of the expression matrix.} 38 | 39 | \item{verbose}{Print messages} 40 | 41 | \item{...}{Extra parameters passed to \code{\link[batchelor]{fastMNN}}} 42 | 43 | \item{reduction.name}{Name to store resulting DimReduc object as} 44 | } 45 | \value{ 46 | A Seurat object merged from the objects in \code{object.list} and a 47 | new DimReduc of name \code{reduction.name} (key set to \code{reduction.key}) 48 | with corrected embeddings matrix as well as the rotation matrix used for the 49 | PCA stored in the feature loadings slot. Also returns an expression matrix 50 | reconstructed from the low-rank approximation in the 51 | \code{reconstructed.assay} assay; all other metadata info 52 | \code{\link[batchelor]{fastMNN}} is stored in the \code{tool} slot, 53 | accessible with \code{\link[Seurat]{Tool}} 54 | } 55 | \description{ 56 | Run fastMNN in Seurat 5 57 | } 58 | \note{ 59 | This function requires the 60 | \href{https://rdrr.io/github/LTLA/batchelor/}{\pkg{batchelor}} package 61 | to be installed 62 | } 63 | \examples{ 64 | \dontrun{ 65 | # Preprocessing 66 | obj <- SeuratData::LoadData("pbmcsca") 67 | obj[["RNA"]] <- split(obj[["RNA"]], f = obj$Method) 68 | obj <- NormalizeData(obj) 69 | obj <- FindVariableFeatures(obj) 70 | obj <- ScaleData(obj) 71 | obj <- RunPCA(obj) 72 | 73 | # After preprocessing, we integrate layers: 74 | obj <- IntegrateLayers(object = obj, method = FastMNNIntegration, 75 | new.reduction = 'integrated.mnn', verbose = FALSE) 76 | 77 | # We can also add parameters specific to FastMNN. 78 | # Here we set `k` to specify the number of nearest neighbors to use when identifying MNNs: 79 | obj <- IntegrateLayers(object = obj, method = FastMNNIntegration, 80 | new.reduction = 'integrated.mnn', k = 15, verbose = FALSE) 81 | } 82 | 83 | } 84 | \seealso{ 85 | \code{\link[batchelor]{fastMNN}} \code{\link[Seurat]{Tool}} 86 | } 87 | -------------------------------------------------------------------------------- /man/LearnGraph.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/monocle3.R 3 | \name{LearnGraph} 4 | \alias{LearnGraph} 5 | \title{Run \code{link[monocle3]{learn_graph}} on a \code{\link[Seurat]{Seurat}} object} 6 | \usage{ 7 | LearnGraph(object, reduction = DefaultDimReduc(object = object), ...) 8 | } 9 | \arguments{ 10 | \item{object}{A \code{\link[Seurat]{Seurat}} object} 11 | 12 | \item{reduction}{Name of reduction to use for learning the pseudotime graph} 13 | 14 | \item{...}{Arguments passed to \code{\link[monocle3]{learn_graph}}} 15 | } 16 | \value{ 17 | A \code{\link[monocle3]{cell_data_set}} object with the pseudotime graph 18 | } 19 | \description{ 20 | Run \code{link[monocle3]{learn_graph}} on a \code{\link[Seurat]{Seurat}} object 21 | } 22 | \seealso{ 23 | \code{\link[monocle3]{learn_graph}} \code{\link[monocle3]{cell_data_set}} 24 | } 25 | -------------------------------------------------------------------------------- /man/PlotMiQC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/miqc.R 3 | \name{PlotMiQC} 4 | \alias{PlotMiQC} 5 | \title{Run miQC on a Seurat object} 6 | \usage{ 7 | PlotMiQC( 8 | seurat_object, 9 | percent.mt = "percent.mt", 10 | nFeature_RNA = "nFeature_RNA", 11 | model.slot = "flexmix_model", 12 | color.by = "miQC.probability" 13 | ) 14 | } 15 | \arguments{ 16 | \item{object}{Seurat object} 17 | } 18 | \description{ 19 | Run miQC on a Seurat object 20 | } 21 | \details{ 22 | _Function to plot the miQC mixture model stored in a Seurat object. `RunMiQC` must be run prior to plotting._ 23 | } 24 | \references{ 25 | Hippen et al. (2021) miQC: An adaptive probabilistic framework for quality control of single-cell RNA-sequencing data. bioRxiv doi: 10.1101/2021.03.03.433798 26 | } 27 | -------------------------------------------------------------------------------- /man/ReadAlevin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/alevin.R 3 | \name{ReadAlevin} 4 | \alias{ReadAlevin} 5 | \title{Load alevin quantification data} 6 | \usage{ 7 | ReadAlevin(file, getMeta = FALSE, meanAndVariance = FALSE, ...) 8 | } 9 | \arguments{ 10 | \item{file}{path to \code{quants_mat.gz} file within 11 | alevin directory} 12 | 13 | \item{getMeta}{logical, option to use \code{tximeta} to 14 | programmatically obtain gene range information, default 15 | is FALSE. Ranges are stored in \code{chr}, \code{start}, 16 | and \code{end} in the \code{meta.features} slot.} 17 | 18 | \item{meanAndVariance}{logical, should mean and variance 19 | of counts be returned in \code{counts} and \code{data} 20 | slots, respectively} 21 | 22 | \item{...}{extra arguments passed to \code{tximport}, 23 | for example, 24 | \code{alevinArgs=list(filterBarcodes=TRUE)}.} 25 | } 26 | \value{ 27 | returns a Seurat object with alevin counts 28 | } 29 | \description{ 30 | A wrapper around tximport to create a \code{SeuratObject} 31 | from alevin quantification data. 32 | } 33 | \references{ 34 | Srivastava, Avi, et al. "Alevin efficiently 35 | estimates accurate gene abundances from dscRNA-seq data." 36 | Genome biology 20.1 (2019): 65. 37 | } 38 | \seealso{ 39 | \code{\link[alevin]{alevin}} 40 | } 41 | \author{ 42 | Avi Srivastava 43 | } 44 | -------------------------------------------------------------------------------- /man/ReadVelocity.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/velocity.R 3 | \name{ReadVelocity} 4 | \alias{ReadVelocity} 5 | \title{Load RNA Velocity data from a loom file} 6 | \usage{ 7 | ReadVelocity(file, engine = "hdf5r", verbose = TRUE) 8 | } 9 | \arguments{ 10 | \item{file}{Path to loom file} 11 | 12 | \item{engine}{Method to load data data, choose from 'hdf5r' or 'h5'} 13 | 14 | \item{verbose}{Display progress updates} 15 | } 16 | \description{ 17 | This is a wrapper around \code{\link[velocyto.R]{read.loom.matrices}}, but sends 18 | messages to \code{stderr} instead of \code{stdout} (or silences messages with 19 | \code{verbose = FALSE}) 20 | } 21 | \seealso{ 22 | \code{\link[velocyto.R]{read.loom.matrices}} 23 | } 24 | -------------------------------------------------------------------------------- /man/RunALRA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/alra.R 3 | \name{RunALRA} 4 | \alias{RunALRA} 5 | \alias{RunALRA.default} 6 | \alias{RunALRA.Seurat} 7 | \title{Run Adaptively-thresholded Low Rank Approximation (ALRA)} 8 | \usage{ 9 | RunALRA(object, ...) 10 | 11 | \method{RunALRA}{default}( 12 | object, 13 | k = NULL, 14 | q = 10, 15 | quantile.prob = 0.001, 16 | use.mkl = FALSE, 17 | mkl.seed = -1, 18 | ... 19 | ) 20 | 21 | \method{RunALRA}{Seurat}( 22 | object, 23 | k = NULL, 24 | q = 10, 25 | quantile.prob = 0.001, 26 | use.mkl = FALSE, 27 | mkl.seed = -1, 28 | assay = NULL, 29 | slot = "data", 30 | setDefaultAssay = TRUE, 31 | genes.use = NULL, 32 | K = NULL, 33 | thresh = 6, 34 | noise.start = NULL, 35 | q.k = 2, 36 | k.only = FALSE, 37 | ... 38 | ) 39 | } 40 | \arguments{ 41 | \item{object}{An object} 42 | 43 | \item{...}{Arguments passed to other methods} 44 | 45 | \item{k}{The rank of the rank-k approximation. Set to NULL for automated choice of k.} 46 | 47 | \item{q}{The number of additional power iterations in randomized SVD when 48 | computing rank k approximation. By default, q=10.} 49 | 50 | \item{quantile.prob}{The quantile probability to use when calculating threshold. 51 | By default, quantile.prob = 0.001.} 52 | 53 | \item{use.mkl}{Use the Intel MKL based implementation of SVD. Needs to be 54 | installed from https://github.com/KlugerLab/rpca-mkl.} 55 | 56 | \item{mkl.seed}{Only relevant if use.mkl=T. Set the seed for the random 57 | generator for the Intel MKL implementation of SVD. Any number <0 will 58 | use the current timestamp. If use.mkl=F, set the seed using 59 | set.seed() function as usual.} 60 | 61 | \item{assay}{Assay to use} 62 | 63 | \item{slot}{slot to use} 64 | 65 | \item{setDefaultAssay}{If TRUE, will set imputed results as default Assay} 66 | 67 | \item{genes.use}{genes to impute} 68 | 69 | \item{K}{Number of singular values to compute when choosing k. Must be less 70 | than the smallest dimension of the matrix. Default 100 or smallest dimension.} 71 | 72 | \item{noise.start}{Index for which all smaller singular values are considered noise. 73 | Default K - 20.} 74 | 75 | \item{q.k}{Number of additional power iterations when choosing k. Default 2.} 76 | 77 | \item{k.only}{If TRUE, only computes optimal k WITHOUT performing ALRA} 78 | 79 | \item{p.val.th}{The threshold for ''significance'' when choosing k. Default 1e-10.} 80 | } 81 | \description{ 82 | Runs ALRA, a method for imputation of dropped out values in scRNA-seq data. 83 | Computes the k-rank approximation to A_norm and adjusts it according to the 84 | error distribution learned from the negative values. Described in 85 | Linderman, G. C., Zhao, J., Kluger, Y. (2018). "Zero-preserving imputation 86 | of scRNA-seq data using low rank approximation." (bioRxiv:138677) 87 | } 88 | \examples{ 89 | \dontrun{ 90 | pbmc_small 91 | # Example 1: Simple usage, with automatic choice of k. 92 | pbmc_small_alra <- RunALRA(object = pbmc_small) 93 | # Example 2: Visualize choice of k, then run ALRA 94 | # First, choose K 95 | pbmc_small_alra <- RunALRA(pbmc_small, k.only=TRUE) 96 | # Plot the spectrum, spacings, and p-values which are used to choose k 97 | ggouts <- ALRAChooseKPlot(pbmc_small_alra) 98 | do.call(gridExtra::grid.arrange, c(ggouts, nrow=1)) 99 | # Run ALRA with the chosen k 100 | pbmc_small_alra <- RunALRA(pbmc_small_alra) 101 | } 102 | 103 | } 104 | \references{ 105 | Linderman, G. C., Zhao, J., Kluger, Y. (2018). "Zero-preserving imputation 106 | of scRNA-seq data using low rank approximation." (bioRxiv:138677) 107 | } 108 | \seealso{ 109 | \code{\link{ALRAChooseKPlot}} 110 | } 111 | \author{ 112 | Jun Zhao, George Linderman 113 | } 114 | -------------------------------------------------------------------------------- /man/RunBanksy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/banksy.R 3 | \name{RunBanksy} 4 | \alias{RunBanksy} 5 | \title{Run Banksy on a Seurat Object} 6 | \usage{ 7 | RunBanksy( 8 | object, 9 | lambda, 10 | assay = "RNA", 11 | slot = "data", 12 | use_agf = FALSE, 13 | dimx = NULL, 14 | dimy = NULL, 15 | dimz = NULL, 16 | ndim = 2, 17 | features = "variable", 18 | group = NULL, 19 | split.scale = TRUE, 20 | k_geom = 15, 21 | n = 2, 22 | sigma = 1.5, 23 | alpha = 0.05, 24 | k_spatial = 10, 25 | spatial_mode = "kNN_median", 26 | assay_name = "BANKSY", 27 | M = NULL, 28 | verbose = TRUE 29 | ) 30 | } 31 | \arguments{ 32 | \item{object}{A Seurat object} 33 | 34 | \item{lambda}{(numeric) Spatial weight parameter} 35 | 36 | \item{assay}{(character) Assay in Seurat object to use} 37 | 38 | \item{slot}{(character) Slot in Seurat assay to use} 39 | 40 | \item{use_agf}{(boolean) Whether to use the AGF} 41 | 42 | \item{dimx}{(character) Column name of spatial x dimension (must be in metadata)} 43 | 44 | \item{dimy}{(character) Column name of spatial y dimension (must be in metadata)} 45 | 46 | \item{dimz}{(character) Column name of spatial z dimension (must be in metadata)} 47 | 48 | \item{ndim}{(integer) Number of spatial dimensions to extract} 49 | 50 | \item{features}{(character) Features to compute. Can be 'all', 'variable' or 51 | a vector of feature names} 52 | 53 | \item{group}{(character) Column name of a grouping variable (must be in metadata)} 54 | 55 | \item{split.scale}{(boolean) Whether to separate scaling by group} 56 | 57 | \item{k_geom}{(numeric) kNN parameter - number of neighbors to use} 58 | 59 | \item{n}{(numeric) kNN_rn parameter - exponent of radius} 60 | 61 | \item{sigma}{(numeric) rNN parameter - standard deviation of Gaussian kernel} 62 | 63 | \item{alpha}{(numeric) rNN parameter - determines radius used} 64 | 65 | \item{k_spatial}{(numeric) rNN parameter - number of neighbors to use} 66 | 67 | \item{spatial_mode}{(character) Kernel for neighborhood computation 68 | \itemize{ 69 | \item{kNN_median: k-nearest neighbors with median-scaled Gaussian kernel} 70 | \item{kNN_r: k-nearest neighbors with $1/r$ kernel} 71 | \item{kNN_rn: k-nearest neighbors with $1/r^n$ kernel} 72 | \item{kNN_rank: k-nearest neighbors with rank Gaussian kernel} 73 | \item{kNN_unif: k-nearest neighbors wth uniform kernel} 74 | \item{rNN_gauss: radial nearest neighbors with Gaussian kernel} 75 | }} 76 | 77 | \item{assay_name}{(character) Name for Banksy assay in Seurat object} 78 | 79 | \item{M}{(numeric) Advanced usage. Highest azimuthal harmonic} 80 | 81 | \item{verbose}{(boolean) Print messages} 82 | } 83 | \value{ 84 | A Seurat object with new assay holding a Banksy matrix 85 | } 86 | \description{ 87 | Run Banksy on a Seurat Object 88 | } 89 | \references{ 90 | Vipul Singhal, Nigel Chou et. al. BANKSY: A Spatial Omics 91 | Algorithm that Unifies Cell Type Clustering and Tissue Domain Segmentation 92 | } 93 | \seealso{ 94 | \code{\link[Banksy]{ComputeBanksy}} 95 | } 96 | \author{ 97 | Joseph Lee, Vipul Singhal 98 | } 99 | -------------------------------------------------------------------------------- /man/RunCoGAPS.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cogaps.R 3 | \name{RunCoGAPS} 4 | \alias{RunCoGAPS} 5 | \title{Run CoGAPs on a Seurat object} 6 | \usage{ 7 | RunCoGAPS( 8 | object, 9 | assay = NULL, 10 | slot = "counts", 11 | params = NULL, 12 | temp.file = NULL, 13 | reduction.name = "CoGAPS", 14 | reduction.key = "CoGAPS_", 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{object}{Seurat object} 20 | 21 | \item{assay}{Assay to pull data from} 22 | 23 | \item{slot}{Slot to pull data from.} 24 | 25 | \item{params}{\code{\link[CoGAPS]{CogapsParams}} object for specifying parameter settings} 26 | 27 | \item{temp.file}{Name of temporary data matrix file to create if running in a distributed mode. 28 | Setting to TRUE will generate the file name using \code{tempfile}.} 29 | 30 | \item{reduction.name}{Name of the CoGAPS reduction returned} 31 | 32 | \item{reduction.key}{Key for the CoGAPS reduction returned} 33 | } 34 | \value{ 35 | Returns a Seurat object with the CoGAPS results stored as a \code{\link{DimReduc}} object 36 | } 37 | \description{ 38 | Run CoGAPs on a Seurat object 39 | } 40 | \references{ 41 | E.J. Fertig, J. Ding, A.V. Favorov, G. Parmigiani, and M.F. Ochs (2010) CoGAPS: an 42 | integrated R/C++ package to identify overlapping patterns of activation of biological processes 43 | from expression data. Bioinformatics 26:2792-2793. 44 | } 45 | \seealso{ 46 | \code{\link[CoGAPS]{CoGAPS}} 47 | } 48 | -------------------------------------------------------------------------------- /man/RunFastMNN.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fast_mnn.R 3 | \name{RunFastMNN} 4 | \alias{RunFastMNN} 5 | \title{Run fastMNN} 6 | \usage{ 7 | RunFastMNN( 8 | object.list, 9 | assay = NULL, 10 | features = 2000, 11 | reduction.name = "mnn", 12 | reduction.key = "mnn_", 13 | reconstructed.assay = "mnn.reconstructed", 14 | verbose = TRUE, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{object.list}{A list of Seurat objects} 20 | 21 | \item{assay}{Assay to use, defaults to the default assay of the first object} 22 | 23 | \item{features}{Either a list of features to use when calculating batch 24 | correction, or a number (2000 by default) of variable features to select.} 25 | 26 | \item{reduction.name}{Name to store resulting DimReduc object as} 27 | 28 | \item{reduction.key}{Key for resulting DimReduc} 29 | 30 | \item{reconstructed.assay}{Name for the assay containing the low-rank 31 | reconstruction of the expression matrix.} 32 | 33 | \item{verbose}{Print messages from \code{\link[Seurat]{SelectIntegrationFeatures}}} 34 | 35 | \item{...}{Extra parameters passed to \code{\link[batchelor]{fastMNN}}} 36 | } 37 | \value{ 38 | A Seurat object merged from the objects in \code{object.list} and a 39 | new DimReduc of name \code{reduction.name} (key set to \code{reduction.key}) 40 | with corrected embeddings matrix as well as the rotation matrix used for the 41 | PCA stored in the feature loadings slot. Also returns an expression matrix 42 | reconstructed from the low-rank approximation in the 43 | \code{reconstructed.assay} assay; all other metadata info 44 | \code{\link[batchelor]{fastMNN}} is stored in the \code{tool} slot, 45 | accessible with \code{\link[Seurat]{Tool}} 46 | } 47 | \description{ 48 | Run fastMNN 49 | } 50 | \seealso{ 51 | \code{\link[batchelor]{fastMNN}} \code{\link[Seurat]{Tool}} 52 | } 53 | -------------------------------------------------------------------------------- /man/RunGLMPCA.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/glmpca.R 3 | \name{RunGLMPCA} 4 | \alias{RunGLMPCA} 5 | \title{Run GLMPCA} 6 | \usage{ 7 | RunGLMPCA( 8 | object, 9 | L = 5, 10 | assay = NULL, 11 | features = NULL, 12 | reduction.name = "glmpca", 13 | reduction.key = "GLMPC_", 14 | verbose = TRUE, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{object}{A Seurat object} 20 | 21 | \item{L}{The number of dimensions to return (defaults to 5)} 22 | 23 | \item{assay}{Assay to use, defaults to the default assay} 24 | 25 | \item{features}{A list of features to use when performing GLM-PCA. If null, defaults to variable features.} 26 | 27 | \item{reduction.name}{Name to store resulting DimReduc object as. Defaults to glmpca} 28 | 29 | \item{reduction.key}{Key for resulting DimReduc. Defaults to GLMPC_} 30 | 31 | \item{...}{Extra parameters passed to \code{\link[glmpca]{glmpca}}} 32 | } 33 | \value{ 34 | A Seurat object containing the output of GLMPCA stored as a DimReduc object. 35 | } 36 | \description{ 37 | Run GLMPCA 38 | } 39 | \examples{ 40 | \dontrun{ 41 | pbmc_small 42 | pbmc_small <- RunGLMPCA(pbmc_small) 43 | DimPlot(pbmc_small, redunction = 'glmpca') 44 | } 45 | 46 | } 47 | \references{ 48 | Townes, W., Hicks, SC, Aryee, MJ, Irizarry, RA. (2019). "Feature selection and dimension reduction for single-cell RNA-Seq based on a multinomial model." 49 | Genome Biology. 50 | } 51 | \author{ 52 | Will Townes 53 | } 54 | -------------------------------------------------------------------------------- /man/RunMiQC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/miqc.R 3 | \name{RunMiQC} 4 | \alias{RunMiQC} 5 | \title{Run miQC on a Seurat object} 6 | \usage{ 7 | RunMiQC( 8 | object, 9 | percent.mt = "percent.mt", 10 | nFeature_RNA = "nFeature_RNA", 11 | posterior.cutoff = 0.75, 12 | model.type = "linear", 13 | model.slot = "flexmix_model", 14 | verbose = TRUE, 15 | backup.option = "percentile", 16 | backup.percentile = 0.99, 17 | backup.percent = 5, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{object}{Seurat object} 23 | 24 | \item{percent.mt}{(character) Name of the column in the Seurat metadata that 25 | contains the percent of reads attributed to mitochondrial genes. 26 | Defaults to "percent.mt".} 27 | 28 | \item{nFeature_RNA}{(character) Name of the column in the Seurat metadata that 29 | contains the number of reads per cell. Defaults to "nFeature_RNA".} 30 | 31 | \item{posterior.cutoff}{numeric) The posterior probability of a cell being 32 | part of the compromised distribution, a number between 0 and 1. Any cells 33 | below the appointed cutoff will be marked to keep. 34 | Defaults to 0.75.} 35 | 36 | \item{model.type}{(character) What type of model to generate. A linear 37 | mixture model ("linear") is recommended, but currently b-spline ("spline") 38 | and two-degree polynomial ("polynomial") are also supported 39 | Default = "linear".} 40 | 41 | \item{verbose}{Boolean. TRUE to show progress messages, FALSE to hide progress messages} 42 | 43 | \item{backup.option}{(character) In case flexmix fails to build a 2 cluster 44 | mixture model, what should RunMiQC do: "percent" (set miQC.keep values 45 | according to backup.percent), "percentile" (set miQC.keep values according 46 | to backup.percentile), "pass" (return original Seurat object), or "halt" 47 | (stop RunMiQC). "percent", "percentile", and "pass" are useful when 48 | processing multiple Seurat objects sequentially.} 49 | 50 | \item{backup.percentile}{(numeric) What percentile to use as cutoff in case 51 | flexmix fails to build a 2 cluster mixture model. Will only be used if 52 | backup.option is "percentile".} 53 | 54 | \item{backup.percent}{(numeric) What percent to use as cutoff in case flexmix 55 | fails to build a 2 cluster mixture model. Will only be used if 56 | backup.option is "percent".} 57 | } 58 | \value{ 59 | Returns a Seurat object with probabilities and "keep" decisions stored as "miQC.probability" and "miQC.keep" in the object metadata, respectively. 60 | } 61 | \description{ 62 | Run miQC on a Seurat object 63 | } 64 | \details{ 65 | (Copied verbatim from miQC) _Function to fit a two-distribution mixture model on a Seurat object and find those cells probabistically determined to be compromised by the mixture model._ 66 | } 67 | \references{ 68 | Hippen et al. (2021) miQC: An adaptive probabilistic framework for quality control of single-cell RNA-sequencing data. bioRxiv doi: 10.1101/2021.03.03.433798 69 | } 70 | -------------------------------------------------------------------------------- /man/RunOptimizeALS.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/liger.R 3 | \name{RunOptimizeALS} 4 | \alias{RunOptimizeALS} 5 | \alias{optimizeALS} 6 | \title{Run optimizeALS on a Seurat object} 7 | \usage{ 8 | RunOptimizeALS( 9 | object, 10 | k, 11 | assay = NULL, 12 | split.by = "orig.ident", 13 | lambda = 5, 14 | thresh = 1e-06, 15 | max.iters = 30, 16 | reduction.name = "iNMF_raw", 17 | reduction.key = "riNMF_", 18 | nrep = 1, 19 | H.init = NULL, 20 | W.init = NULL, 21 | V.init = NULL, 22 | rand.seed = 1, 23 | print.obj = FALSE, 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{object}{A merged Seurat object} 29 | 30 | \item{k}{Inner dimension of factorization (number of factors). Run suggestK to determine 31 | appropriate value; a general rule of thumb is that a higher k will be needed for datasets with 32 | more sub-structure.} 33 | 34 | \item{assay}{Assay to use, defaults to the default assay of the first object} 35 | 36 | \item{split.by}{Attribute for splitting, defaults to "orig.ident"} 37 | 38 | \item{lambda}{Regularization parameter. Larger values penalize dataset-specific effects more 39 | strongly (ie. alignment should increase as lambda increases). Run suggestLambda to determine 40 | most appropriate value for balancing dataset alignment and agreement (default 5.0).} 41 | 42 | \item{thresh}{Convergence threshold. Convergence occurs when |obj0-obj|/(mean(obj0,obj)) < thresh. 43 | (default 1e-6)} 44 | 45 | \item{max.iters}{Maximum number of block coordinate descent iterations to perform (default 30).} 46 | 47 | \item{reduction.name}{Name to store resulting DimReduc object as} 48 | 49 | \item{reduction.key}{Key for resulting DimReduc} 50 | 51 | \item{nrep}{Number of restarts to perform (iNMF objective function is non-convex, so taking the 52 | best objective from multiple successive initializations is recommended). For easier 53 | reproducibility, this increments the random seed by 1 for each consecutive restart, so future 54 | factorizations of the same dataset can be run with one rep if necessary. (default 1)} 55 | 56 | \item{H.init}{Initial values to use for H matrices. (default NULL)} 57 | 58 | \item{W.init}{Initial values to use for W matrix (default NULL)} 59 | 60 | \item{V.init}{Initial values to use for V matrices (default NULL)} 61 | 62 | \item{rand.seed}{Random seed to allow reproducible results (default 1).} 63 | 64 | \item{print.obj}{Print objective function values after convergence (default FALSE).} 65 | 66 | \item{...}{Arguments passed to other methods} 67 | } 68 | \value{ 69 | A Seurat object with embeddings and loadings from \code{\link[liger]{optimizeALS}} 70 | stored as a DimReduc object with name \code{reduction.name} (key set to \code{reduction.key}); 71 | per-dataset feature loadings matrices stored in the \code{tool} slot, accessible with 72 | \code{\link[Seurat]{Tool}} 73 | } 74 | \description{ 75 | Run optimizeALS on a Seurat object 76 | } 77 | \seealso{ 78 | \code{\link[rliger]{optimizeALS}} \code{\link[Seurat]{Tool}} 79 | } 80 | -------------------------------------------------------------------------------- /man/RunPaCMAP.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pacmap.R 3 | \name{RunPaCMAP} 4 | \alias{RunPaCMAP} 5 | \alias{RunPaCMAP.Seurat} 6 | \alias{RunPaCMAP.default} 7 | \title{Run PaCMAP (Pairwise Controlled Manifold Approximation)} 8 | \usage{ 9 | RunPaCMAP(object, ...) 10 | 11 | \method{RunPaCMAP}{Seurat}( 12 | object, 13 | reduction = "pca", 14 | dims = NULL, 15 | features = NULL, 16 | assay = NULL, 17 | layer = "data", 18 | n_components = 2, 19 | n.neighbors = NULL, 20 | MN_ratio = 0.5, 21 | FP_ratio = 2, 22 | distance_method = "euclidean", 23 | lr = 1, 24 | num_iters = 250L, 25 | apply_pca = TRUE, 26 | init = "random", 27 | reduction.name = "pacmap", 28 | reduction.key = "PaCMAP_", 29 | verbose = TRUE, 30 | seed.use = 11L, 31 | ... 32 | ) 33 | 34 | \method{RunPaCMAP}{default}( 35 | object, 36 | assay = NULL, 37 | n_components = 2, 38 | n.neighbors = NULL, 39 | MN_ratio = 0.5, 40 | FP_ratio = 2, 41 | distance_method = "euclidean", 42 | lr = 1, 43 | num_iters = 250L, 44 | apply_pca = TRUE, 45 | init = "random", 46 | reduction.key = "PaCMAP_", 47 | verbose = TRUE, 48 | seed.use = 11L, 49 | ... 50 | ) 51 | } 52 | \arguments{ 53 | \item{object}{An object. This can be a Seurat object or a matrix-like object.} 54 | 55 | \item{...}{Additional arguments to be passed to the pacmap.PaCMAP function.} 56 | 57 | \item{reduction}{A character string specifying the reduction to be used as input. Default is "pca".} 58 | 59 | \item{dims}{An integer vector specifying the dimensions to be used. Default is NULL.} 60 | 61 | \item{features}{A character vector specifying the features to be used. Default is NULL.} 62 | 63 | \item{assay}{A character string specifying the assay to be used. Default is NULL.} 64 | 65 | \item{layer}{A character string specifying the layer name to be used. Default is "data".} 66 | 67 | \item{n_components}{An integer specifying the number of PaCMAP components. Default is 2.} 68 | 69 | \item{n.neighbors}{An integer specifying the number of neighbors considered in the k-Nearest Neighbor graph. Default to 10 for dataset whose sample size is smaller than 10000. For large dataset whose sample size (n) is larger than 10000, the default value is: 10 + 15 * (log10(n) - 4).} 70 | 71 | \item{MN_ratio}{A numeric value specifying the ratio of the ratio of the number of mid-near pairs to the number of neighbors. Default is 0.5.} 72 | 73 | \item{FP_ratio}{A numeric value specifying the ratio of the ratio of the number of further pairs to the number of neighbors. Default is 2.} 74 | 75 | \item{distance_method}{A character string specifying the distance metric to be used. Default is "euclidean".} 76 | 77 | \item{lr}{A numeric value specifying the learning rate of the AdaGrad optimizer. Default is 1.} 78 | 79 | \item{num_iters}{An integer specifying the number of iterations for PaCMAP optimization. Default is 450.} 80 | 81 | \item{apply_pca}{A logical value indicating whether pacmap should apply PCA to the data before constructing the k-Nearest Neighbor graph. Using PCA to preprocess the data can largely accelerate the DR process without losing too much accuracy. Notice that this option does not affect the initialization of the optimization process. Default is TRUE.} 82 | 83 | \item{init}{A character string specifying the initialization of the lower dimensional embedding. One of "pca" or "random". Default is "random".} 84 | 85 | \item{reduction.name}{A character string specifying the name of the reduction to be stored in the Seurat object. Default is "pacmap".} 86 | 87 | \item{reduction.key}{A character string specifying the prefix for the column names of the PaCMAP embeddings. Default is "PaCMAP_".} 88 | 89 | \item{verbose}{A logical value indicating whether to print verbose output. Default is TRUE.} 90 | 91 | \item{seed.use}{An integer specifying the random seed to be used. Default is 11.} 92 | 93 | \item{slot}{A character string specifying the slot name to be used. Default is "data".} 94 | } 95 | \description{ 96 | Runs PaCMAP, a method for dimensionality reduction for scRNA-seq data. 97 | data. Constructs three kinds of pairs of points: neighbor pairs (pair_neighbors), 98 | mid-near pair (pair_MN), and further pairs (pair_FP) based on positional relationship 99 | in the original space, and optimize a low-dimensional embedding accordingly. 100 | Described in Wang, Y., Huang, H., Rudin, C., & Shaposhnik, Y. (2021). "Understanding 101 | how dimension reduction tools work: an empirical approach to deciphering t-SNE, UMAP, 102 | TriMAP, and PaCMAP for data visualization." Journal of Machine Learning Research, 103 | 22(201), 1-73. 104 | This implementation is based on the work of Hao Zhang, as found in 105 | https://github.com/zhanghao-njmu/SCP/. We made modifications to ensure compatibility 106 | across multiple platforms, including Windows and macOS. 107 | } 108 | \examples{ 109 | pancreas_sub <- Seurat::FindVariableFeatures(pancreas_sub) 110 | pancreas_sub <- RunPaCMAP(object = pancreas_sub, features = Seurat::VariableFeatures(pancreas_sub)) 111 | DimPlot(pancreas_sub, reduction = "pacmap") 112 | 113 | } 114 | \references{ 115 | Wang, Y., Huang, H., Rudin, C., & Shaposhnik, Y. (2021). "Understanding 116 | how dimension reduction tools work: an empirical approach to deciphering t-SNE, UMAP, 117 | TriMAP, and PaCMAP for data visualization." Journal of Machine Learning Research, 118 | 22(201), 1-73. 119 | } 120 | \author{ 121 | Yiyang Sun, Haiyang Huang, Gaurav Rajesh Parikh 122 | } 123 | -------------------------------------------------------------------------------- /man/RunPresto.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/presto.R 3 | \name{RunPresto} 4 | \alias{RunPresto} 5 | \title{A Presto-based implementation of FindMarkers that runs Wilcoxon tests for the given identity classes} 6 | \usage{ 7 | RunPresto( 8 | object, 9 | ident.1 = NULL, 10 | ident.2 = NULL, 11 | group.by = NULL, 12 | subset.ident = NULL, 13 | assay = NULL, 14 | slot = "data", 15 | reduction = NULL, 16 | features = NULL, 17 | logfc.threshold = 0.25, 18 | test.use = "wilcox", 19 | min.pct = 0.1, 20 | min.diff.pct = -Inf, 21 | verbose = TRUE, 22 | only.pos = FALSE, 23 | max.cells.per.ident = Inf, 24 | random.seed = 1, 25 | latent.vars = NULL, 26 | min.cells.feature = 3, 27 | min.cells.group = 3, 28 | mean.fxn = NULL, 29 | fc.name = NULL, 30 | base = 2, 31 | ... 32 | ) 33 | } 34 | \arguments{ 35 | \item{ident.1}{Identity class to define markers for; pass an object of class 36 | \code{phylo} or 'clustertree' to find markers for a node in a cluster tree; 37 | passing 'clustertree' requires \code{\link{BuildClusterTree}} to have been run} 38 | 39 | \item{ident.2}{A second identity class for comparison; if \code{NULL}, 40 | use all other cells for comparison; if an object of class \code{phylo} or 41 | 'clustertree' is passed to \code{ident.1}, must pass a node to find markers for} 42 | 43 | \item{group.by}{Regroup cells into a different identity class prior to performing differential expression (see example)} 44 | 45 | \item{subset.ident}{Subset a particular identity class prior to regrouping. Only relevant if group.by is set (see example)} 46 | 47 | \item{assay}{Assay to use in differential expression testing} 48 | 49 | \item{slot}{Slot to pull data from; note that if \code{test.use} is "negbinom", "poisson", or "DESeq2", 50 | \code{slot} will be set to "counts"} 51 | 52 | \item{reduction}{Reduction to use in differential expression testing - will test for DE on cell embeddings} 53 | 54 | \item{mean.fxn}{Function to use for fold change or average difference calculation. 55 | If NULL, the appropriate function will be chose according to the slot used} 56 | 57 | \item{fc.name}{Name of the fold change, average difference, or custom function column 58 | in the output data.frame. If NULL, the fold change column will be named 59 | according to the logarithm base (eg, "avg_log2FC"), or if using the scale.data 60 | slot "avg_diff".} 61 | 62 | \item{base}{The base with respect to which logarithms are computed.} 63 | } 64 | \description{ 65 | A Presto-based implementation of FindMarkers that runs Wilcoxon tests for the given identity classes 66 | } 67 | \seealso{ 68 | https://github.com/immunogenomics/presto 69 | } 70 | -------------------------------------------------------------------------------- /man/RunPrestoAll.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/presto.R 3 | \name{RunPrestoAll} 4 | \alias{RunPrestoAll} 5 | \alias{RunPrestoAllNode} 6 | \title{A Presto-based implementation of FindAllMarkers that runs Wilcoxon tests for all identity classes} 7 | \usage{ 8 | RunPrestoAll( 9 | object, 10 | assay = NULL, 11 | features = NULL, 12 | logfc.threshold = 0.25, 13 | test.use = "wilcox", 14 | slot = "data", 15 | min.pct = 0.1, 16 | min.diff.pct = -Inf, 17 | node = NULL, 18 | verbose = TRUE, 19 | only.pos = FALSE, 20 | max.cells.per.ident = Inf, 21 | random.seed = 1, 22 | latent.vars = NULL, 23 | min.cells.feature = 3, 24 | min.cells.group = 3, 25 | mean.fxn = NULL, 26 | fc.name = NULL, 27 | base = 2, 28 | return.thresh = 0.01, 29 | ... 30 | ) 31 | } 32 | \arguments{ 33 | \item{assay}{Assay to use in differential expression testing} 34 | 35 | \item{slot}{Slot to pull data from; note that if \code{test.use} is "negbinom", "poisson", or "DESeq2", 36 | \code{slot} will be set to "counts"} 37 | 38 | \item{node}{A node to find markers for and all its children; requires 39 | \code{\link{BuildClusterTree}} to have been run previously; replaces \code{FindAllMarkersNode}} 40 | 41 | \item{mean.fxn}{Function to use for fold change or average difference calculation. 42 | If NULL, the appropriate function will be chose according to the slot used} 43 | 44 | \item{fc.name}{Name of the fold change, average difference, or custom function column 45 | in the output data.frame. If NULL, the fold change column will be named 46 | according to the logarithm base (eg, "avg_log2FC"), or if using the scale.data 47 | slot "avg_diff".} 48 | 49 | \item{base}{The base with respect to which logarithms are computed.} 50 | 51 | \item{return.thresh}{Only return markers that have a p-value < return.thresh, or a power > return.thresh (if the test is ROC)} 52 | } 53 | \value{ 54 | Matrix containing a ranked list of putative markers, and associated 55 | statistics (p-values, logFC, etc.) 56 | } 57 | \description{ 58 | Finds markers (Wilcoxon-differentially expressed genes) for each of the identity classes in a dataset 59 | } 60 | \seealso{ 61 | https://github.com/immunogenomics/presto 62 | } 63 | -------------------------------------------------------------------------------- /man/RunQuantileAlignSNF.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/liger.R 3 | \name{RunQuantileAlignSNF} 4 | \alias{RunQuantileAlignSNF} 5 | \alias{quantileAlignSNF} 6 | \title{Run quantileAlignSNF on a Seurat object} 7 | \usage{ 8 | RunQuantileAlignSNF( 9 | object, 10 | split.by = "orig.ident", 11 | reduction = "iNMF_raw", 12 | reduction.name = "iNMF", 13 | reduction.key = "iNMF_", 14 | recalc.snf = FALSE, 15 | ref_dataset = NULL, 16 | prune.thresh = 0.2, 17 | min_cells = 2, 18 | quantiles = 50, 19 | nstart = 10, 20 | resolution = 1, 21 | center = FALSE, 22 | id.number = NULL, 23 | print.mod = FALSE, 24 | print.align.summary = FALSE, 25 | ... 26 | ) 27 | } 28 | \arguments{ 29 | \item{object}{A merged Seurat object} 30 | 31 | \item{split.by}{Attribute for splitting, defaults to "orig.ident"} 32 | 33 | \item{reduction}{Name of reduction to use} 34 | 35 | \item{reduction.name}{Name to store resulting DimReduc object as} 36 | 37 | \item{reduction.key}{Key for resulting DimReduc} 38 | 39 | \item{recalc.snf}{Recalculate \code{\link{SNF}}} 40 | 41 | \item{ref_dataset}{Name of dataset to use as a "reference" for normalization. By default, 42 | the dataset with the largest number of cells is used.} 43 | 44 | \item{prune.thresh}{Minimum allowed edge weight. Any edges below this are removed (given weight 45 | 0) (default 0.2)} 46 | 47 | \item{min_cells}{Minimum number of cells to consider a cluster shared across datasets (default 2)} 48 | 49 | \item{quantiles}{Number of quantiles to use for quantile normalization (default 50).} 50 | 51 | \item{nstart}{Number of times to perform Louvain community detection with different random 52 | starts (default 10).} 53 | 54 | \item{resolution}{Controls the number of communities detected. Higher resolution -> more 55 | communities. (default 1)} 56 | 57 | \item{center}{Centers the data when scaling factors (useful for less sparse modalities like 58 | methylation data). (default FALSE)} 59 | 60 | \item{id.number}{Number to use for identifying edge file (when running in parallel) 61 | (generates random value by default).} 62 | 63 | \item{print.mod}{Print modularity output from clustering algorithm (default FALSE).} 64 | 65 | \item{print.align.summary}{Print summary of clusters which did not align normally (default FALSE).} 66 | 67 | \item{...}{Arguments passed to other methods, and to 68 | \code{\link[seurat.wrappers]{SNF}} if \code{recalc.snf = TRUE} or 69 | \code{\link[seurat.wrappers]{SNF}} hasn't been run} 70 | } 71 | \value{ 72 | A Seurat object with embeddings from \code{\link[liger]{quantileAlignSNF}} 73 | stored as a DimReduc object with name \code{reduction.name} (key set to \code{reduction.key}) 74 | } 75 | \description{ 76 | This is a deprecated function. Call 'RunQuantileNorm' instead. 77 | } 78 | \seealso{ 79 | \code{\link[rliger]{RunQuantileNorm}} 80 | } 81 | -------------------------------------------------------------------------------- /man/RunQuantileNorm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/liger.R 3 | \name{RunQuantileNorm} 4 | \alias{RunQuantileNorm} 5 | \alias{quantile_norm} 6 | \title{Run quantile_norm on a Seurat object} 7 | \usage{ 8 | RunQuantileNorm( 9 | object, 10 | split.by = "orig.ident", 11 | reduction = "iNMF_raw", 12 | reduction.name = "iNMF", 13 | reduction.key = "iNMF_", 14 | quantiles = 50, 15 | ref_dataset = NULL, 16 | min_cells = 20, 17 | knn_k = 20, 18 | dims.use = NULL, 19 | do.center = FALSE, 20 | max_sample = 1000, 21 | eps = 0.9, 22 | refine.knn = TRUE, 23 | ... 24 | ) 25 | } 26 | \arguments{ 27 | \item{object}{A merged Seurat object} 28 | 29 | \item{split.by}{Attribute for splitting, defaults to "orig.ident"} 30 | 31 | \item{reduction.name}{Name to store resulting DimReduc object as} 32 | 33 | \item{reduction.key}{Key for resulting DimReduc} 34 | 35 | \item{quantiles}{Number of quantiles to use for quantile normalization (default 50).} 36 | 37 | \item{ref_dataset}{Name of dataset to use as a "reference" for normalization. By default, 38 | the dataset with the largest number of cells is used.} 39 | 40 | \item{min_cells}{Minimum number of cells to consider a cluster shared across datasets (default 20)} 41 | 42 | \item{knn_k}{Number of nearest neighbors for within-dataset knn graph (default 20).} 43 | 44 | \item{dims.use}{Indices of factors to use for shared nearest factor determination (default 45 | 1:ncol(H[[1]])).} 46 | 47 | \item{do.center}{Centers the data when scaling factors (useful for less sparse modalities like 48 | methylation data). (default FALSE)} 49 | 50 | \item{max_sample}{Maximum number of cells used for quantile normalization of each cluster 51 | and factor. (default 1000)} 52 | 53 | \item{eps}{The error bound of the nearest neighbor search. (default 0.9) Lower values give more 54 | accurate nearest neighbor graphs but take much longer to computer.} 55 | 56 | \item{refine.knn}{whether to increase robustness of cluster assignments using KNN graph.(default TRUE)} 57 | 58 | \item{...}{Arguments passed to other methods} 59 | } 60 | \value{ 61 | A Seurat object with embeddings from \code{\link[liger]{quantile_norm}} 62 | stored as a DimReduc object with name \code{reduction.name} (key set to \code{reduction.key}) 63 | } 64 | \description{ 65 | Run quantile_norm on a Seurat object 66 | } 67 | \seealso{ 68 | \code{\link[rliger]{quantile_norm}} 69 | } 70 | -------------------------------------------------------------------------------- /man/RunSNF.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/liger.R 3 | \name{RunSNF} 4 | \alias{RunSNF} 5 | \alias{SNF} 6 | \title{Generate shared factor neighborhood graph} 7 | \usage{ 8 | RunSNF( 9 | object, 10 | split.by = "orig.ident", 11 | reduction = "iNMF_raw", 12 | dims.use = NULL, 13 | dist.use = "CR", 14 | center = FALSE, 15 | knn_k = 20, 16 | k2 = 500, 17 | small.clust.thresh = knn_k, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{object}{A merged Seurat object} 23 | 24 | \item{split.by}{Attribute for splitting, defaults to "orig.ident"} 25 | 26 | \item{reduction}{Name of reduction to use} 27 | 28 | \item{...}{Arguments passed to other methods} 29 | } 30 | \value{ 31 | A Seurat object with the SNF list stored in the \code{tool} slot, 32 | accessible with \code{\link[Seurat]{Tool}} 33 | } 34 | \description{ 35 | This is a deprecated function. Call 'RunQuantileNorm' instead. 36 | } 37 | \seealso{ 38 | \code{\link[rliger]{RunQuantileNorm}} \code{\link[Seurat]{Tool}} 39 | } 40 | -------------------------------------------------------------------------------- /man/RunVelocity.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/velocity.R 3 | \name{RunVelocity} 4 | \alias{RunVelocity} 5 | \title{Run RNA Velocty} 6 | \usage{ 7 | RunVelocity( 8 | object, 9 | spliced = "spliced", 10 | unspliced = "unspliced", 11 | ambiguous = NULL, 12 | spliced.average = 0.2, 13 | unspliced.average = 0.05, 14 | reduction = "pca", 15 | group.by = "ident", 16 | cells = NULL, 17 | graph = NULL, 18 | ncores = 1, 19 | verbose = TRUE, 20 | ... 21 | ) 22 | } 23 | \arguments{ 24 | \item{object}{A \code{Seurat} object} 25 | 26 | \item{spliced}{Name of spliced assay} 27 | 28 | \item{unspliced}{Name of unspliced assay} 29 | 30 | \item{ambiguous}{Optional name of ambiguous assay} 31 | 32 | \item{spliced.average, unspliced.average}{Required minimum average expression count for the spliced and unspliced expression matrices} 33 | 34 | \item{reduction}{Name of reduction to use} 35 | 36 | \item{group.by}{Factor to group cells by} 37 | 38 | \item{cells}{Vector of cells to use; defaults to all cells 39 | (see \code{\link[velocyto.R]{gene.relative.velocity.estimates}:steady.state.cells})} 40 | 41 | \item{graph}{Optional name of nearest neighbor graph to use} 42 | 43 | \item{ncores}{Number of cores to use} 44 | 45 | \item{verbose}{Display progress updates} 46 | 47 | \item{...}{Extra parameters passed to \code{\link[velocyto.R]{gene.relative.velocity.estimates}}} 48 | } 49 | \value{ 50 | ... 51 | } 52 | \description{ 53 | Run RNA Velocty 54 | } 55 | \seealso{ 56 | \code{\link[velocyto.R]{gene.relative.velocity.estimates}} \code{\link[Seurat]{Tool}} 57 | } 58 | -------------------------------------------------------------------------------- /man/Runtricycle.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tricycle.R 3 | \name{Runtricycle} 4 | \alias{Runtricycle} 5 | \title{Run estimate_cycle_position on a Seurat object} 6 | \usage{ 7 | Runtricycle( 8 | object, 9 | assay = NULL, 10 | slot = "data", 11 | reduction.name = "tricycleEmbedding", 12 | reduction.key = "tricycleEmbedding_", 13 | gname = NULL, 14 | gname.type = c("ENSEMBL", "SYMBOL"), 15 | species = c("mouse", "human"), 16 | AnnotationDb = NULL, 17 | center.pc1 = 0, 18 | center.pc2 = 0 19 | ) 20 | } 21 | \arguments{ 22 | \item{object}{Seurat object} 23 | 24 | \item{assay}{Assay to use, defaults to the default assay} 25 | 26 | \item{slot}{Slot to use. It should be library size adjusted **log-expression** values. 27 | Note that it is convention that we rename "logcounts" to "data" when converting SingleCellExperiment to Seurat object. 28 | See also \code{\link[Seurat]{as.Seurat}}. Defaults to "data"} 29 | 30 | \item{reduction.name}{Name of the cell cycle projection returned} 31 | 32 | \item{reduction.key}{Key for the cell cycle projection returned} 33 | 34 | \item{gname}{Alternative rownames of \code{object}. If provided, this will be used to map genes within \code{object} with genes in reference. 35 | If not provided, the rownames of \code{object} will be used instead. Default: NULL} 36 | 37 | \item{gname.type}{The type of gene names as in \code{gname} or rownames of \code{object}. It can be either 'ENSEMBL' or 'SYMBOL'. Default: 'ENSEMBL'} 38 | 39 | \item{species}{The type of species in \code{object}. It can be either 'mouse' or 'human'. Default: 'mouse'} 40 | 41 | \item{AnnotationDb}{An AnnotationDb objects. If the user provides rownames in the format of Ensembl IDs and project human data, 42 | this object will be used to map Ensembl IDs to gene SYMBOLs. If no AnnotationDb object being given, the function will use \code{\link[org.Hs.eg.db]{org.Hs.eg.db}}.} 43 | 44 | \item{center.pc1}{The center of PC1 when defining the angle. Default: 0} 45 | 46 | \item{center.pc2}{The center of PC2 when defining the angle. Default: 0} 47 | } 48 | \description{ 49 | This function run estimate_cycle_position function on Seurat object. It uses 50 | the tricycle internal reference projection matrix. 51 | } 52 | -------------------------------------------------------------------------------- /man/SeuratWrappers-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/internal.R 3 | \docType{package} 4 | \name{SeuratWrappers-package} 5 | \alias{SeuratWrappers} 6 | \alias{SeuratWrappers-package} 7 | \title{SeuratWrappers: Community-Provided Methods and Extensions for the Seurat Object} 8 | \description{ 9 | SeuratWrappers is a collection of community-provided methods and extensions for Seurat, curated by the Satija Lab at NYGC. These methods comprise functionality not presently found in Seurat, and are able to be updated much more frequently. 10 | } 11 | \author{ 12 | \strong{Maintainer}: Paul Hoffman \email{nygcSatijalab@nygenome.org} (\href{https://orcid.org/0000-0002-7693-8957}{ORCID}) 13 | 14 | Authors: 15 | \itemize{ 16 | \item Andrew Butler \email{abutler@nygenome.org} (\href{https://orcid.org/0000-0003-3608-0463}{ORCID}) 17 | \item Rahul Satija \email{rsatija@nygenome.org} (\href{https://orcid.org/0000-0001-9448-8833}{ORCID}) 18 | \item Tim Stuart \email{tstuart@nygenome.org} (\href{https://orcid.org/0000-0002-3044-0897}{ORCID}) 19 | } 20 | 21 | Other contributors: 22 | \itemize{ 23 | \item Saket Choudhary \email{schoudhary@nygenome.org} (\href{https://orcid.org/0000-0001-5202-7633}{ORCID}) [contributor] 24 | \item David Collins \email{dcollins@nygenome.org} (\href{https://orcid.org/0000-0001-9243-7821}{ORCID}) [contributor] 25 | \item Yuhan Hao \email{yhao@nygenome.org} (\href{https://orcid.org/0000-0002-1810-0822}{ORCID}) [contributor] 26 | \item Austin Hartman \email{ahartman@nygenome.org} (\href{https://orcid.org/0000-0001-7278-1852}{ORCID}) [contributor] 27 | \item Gesmira Molla \email{gmolla@nygenome.org} (\href{https://orcid.org/0000-0002-8628-5056}{ORCID}) [contributor] 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /man/StopCellbrowser.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cellbrowser.R 3 | \name{StopCellbrowser} 4 | \alias{StopCellbrowser} 5 | \title{Stop Cellbrowser web server} 6 | \usage{ 7 | StopCellbrowser() 8 | } 9 | \description{ 10 | Stop Cellbrowser web server 11 | } 12 | \examples{ 13 | \dontrun{ 14 | StopCellbrowser() 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /man/VeloPlot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/velocity.R 3 | \name{VeloPlot} 4 | \alias{VeloPlot} 5 | \title{RNA Velocity Plot} 6 | \usage{ 7 | VeloPlot(object, reduction = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{...}{Extra parameters passed on to \code{\link[velocyto.R]{show.velocity.on.embedding.cor}}} 11 | } 12 | \value{ 13 | Nothing, shows plot 14 | } 15 | \description{ 16 | RNA Velocity Plot 17 | } 18 | \seealso{ 19 | \code{\link[velocyto.R]{show.velocity.on.embedding.cor}} 20 | } 21 | \keyword{internal} 22 | -------------------------------------------------------------------------------- /man/as.cell_data_set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/monocle3.R 3 | \name{as.cell_data_set} 4 | \alias{as.cell_data_set} 5 | \alias{as.CellDataSet} 6 | \alias{as.cell_data_set.Seurat} 7 | \title{Convert objects to Monocle3 \code{cell_data_set} objects} 8 | \usage{ 9 | as.cell_data_set(x, ...) 10 | 11 | \method{as.cell_data_set}{Seurat}( 12 | x, 13 | assay = DefaultAssay(object = x), 14 | reductions = AssociatedDimReducs(object = x, assay = assay), 15 | default.reduction = DefaultDimReduc(object = x, assay = assay), 16 | graph = paste0(assay, "_snn"), 17 | group.by = NULL, 18 | ... 19 | ) 20 | } 21 | \arguments{ 22 | \item{x}{An object} 23 | 24 | \item{...}{Arguments passed to other methods} 25 | 26 | \item{reductions}{A vector of dimensional reductions add to the 27 | \code{cell_data_set} object; defaults to all dimensional reductions 28 | calculated from \code{assay} and all \link[Seurat:IsGlobal]{global} 29 | dimensional reductions} 30 | 31 | \item{default.reduction}{Name of dimensional reduction to use for clustering 32 | name} 33 | 34 | \item{graph}{Name of graph to be used for clustering results} 35 | 36 | \item{group.by}{Name of cell-level metadata column to use as identites; pass} 37 | } 38 | \value{ 39 | A \code{cell_data_set} object 40 | } 41 | \description{ 42 | Convert objects to Monocle3 \code{cell_data_set} objects 43 | } 44 | \details{ 45 | The \code{\link[Seurat]{Seurat}} method utilizes 46 | \code{\link[Seurat]{as.SingleCellExperiment}} to transfer over expression 47 | and cell-level metadata. The following additional information is also 48 | transferred over: 49 | \itemize{ 50 | \item Cell emebeddings are transferred over to the 51 | \code{\link[SingleCellExperiment]{reducedDims}} slot. Dimensional reduction 52 | names are converted to upper-case (eg. \dQuote{umap} to \dQuote{UMAP}) to 53 | match Monocle 3 style 54 | \item Feature loadings are transfered to 55 | \code{cds@reduce_dim_aux$gene_loadings} if present. \strong{NOTE}: only the 56 | feature loadings of the last dimensional reduction are transferred over 57 | \item Standard deviations are added to 58 | \code{cds@reduce_dim_aux$prop_var_expl} if present. \strong{NOTE}: only the 59 | standard deviations of the last dimensional reduction are transferred over 60 | \item Clustering information is transferred over in the following manner: if 61 | cell-level metadata entries \dQuote{monocle3_clusters} and 62 | \dQuote{monocle3_partitions} exist, then these will be set as the clusters 63 | and partitions, with no nearest neighbor graph being added to the object; 64 | otherwise, Seurat's nearest-neighbor graph will be converted to an 65 | \code{\link[igraph]{igraph}} object and added to the \code{cell_data_set} 66 | object along with Seurat's clusters. No partition information is added when 67 | using Seurat's clsuters 68 | } 69 | } 70 | \seealso{ 71 | \code{\link[Seurat]{as.SingleCellExperiment}} 72 | } 73 | -------------------------------------------------------------------------------- /man/findMatrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cellbrowser.R 3 | \name{findMatrix} 4 | \alias{findMatrix} 5 | \title{used by ExportToCellbrowser: 6 | Return a matrix object from a Seurat object or show an error message} 7 | \usage{ 8 | findMatrix(object, matrix.slot) 9 | } 10 | \arguments{ 11 | \item{object}{Seurat object} 12 | 13 | \item{matrix.slot}{the name of the slot} 14 | } 15 | \description{ 16 | used by ExportToCellbrowser: 17 | Return a matrix object from a Seurat object or show an error message 18 | } 19 | -------------------------------------------------------------------------------- /man/scVIIntegration.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/scVI.R 3 | \name{scVIIntegration} 4 | \alias{scVIIntegration} 5 | \title{scVI Integration} 6 | \usage{ 7 | scVIIntegration( 8 | object, 9 | features = NULL, 10 | layers = "counts", 11 | conda_env = NULL, 12 | new.reduction = "integrated.dr", 13 | ndims = 30, 14 | nlayers = 2, 15 | gene_likelihood = "nb", 16 | max_epochs = NULL, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{object}{A \code{StdAssay} or \code{STDAssay} instance containing 22 | merged data} 23 | 24 | \item{features}{Features to integrate} 25 | 26 | \item{layers}{Layers to integrate} 27 | 28 | \item{conda_env}{conda environment to run scVI} 29 | 30 | \item{new.reduction}{Name under which to store resulting DimReduc object} 31 | 32 | \item{ndims}{Dimensionality of the latent space} 33 | 34 | \item{nlayers}{Number of hidden layers used for encoder and decoder NNs} 35 | 36 | \item{gene_likelihood}{Distribution to use for modelling expression 37 | data: {"zinb", "nb", "poisson"}} 38 | 39 | \item{max_epochs}{Number of passes through the dataset taken while 40 | training the model} 41 | 42 | \item{...}{Unused - currently just capturing parameters passed in from 43 | \code{Seurat::IntegrateLayers} intended for other integration methods} 44 | } 45 | \value{ 46 | A single-element named list \code{DimReduc} elements containing 47 | the integrated data 48 | } 49 | \description{ 50 | scVI Integration 51 | } 52 | \note{ 53 | This function requires the 54 | \href{https://docs.scvi-tools.org/en/stable/installation.html}{\pkg{scvi-tools}} 55 | package to be installed 56 | } 57 | \examples{ 58 | \dontrun{ 59 | # Preprocessing 60 | obj <- SeuratData::LoadData("pbmcsca") 61 | obj[["RNA"]] <- split(obj[["RNA"]], f = obj$Method) 62 | obj <- NormalizeData(obj) 63 | obj <- FindVariableFeatures(obj) 64 | obj <- ScaleData(obj) 65 | obj <- RunPCA(obj) 66 | 67 | # After preprocessing, we integrate layers, specifying a conda environment 68 | obj <- IntegrateLayers( 69 | object = obj, 70 | method = scVIIntegration, 71 | new.reduction = "integrated.scvi", 72 | conda_env = "../miniconda3/envs/scvi-env", 73 | verbose = FALSE 74 | ) 75 | 76 | # Alternatively, we can integrate SCTransformed data 77 | obj <- SCTransform(object = obj) 78 | obj <- IntegrateLayers( 79 | object = obj, method = scVIIntegration, 80 | orig.reduction = "pca", new.reduction = "integrated.scvi", 81 | assay = "SCT", conda_env = "../miniconda3/envs/scvi-env", verbose = FALSE 82 | ) 83 | } 84 | 85 | } 86 | \seealso{ 87 | \href{https://docs.scvi-tools.org/en/stable/tutorials/notebooks/scvi_in_R.html}{scVI} 88 | } 89 | -------------------------------------------------------------------------------- /man/writeSparseTsvChunks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cellbrowser.R 3 | \name{writeSparseTsvChunks} 4 | \alias{writeSparseTsvChunks} 5 | \title{Used by \code{ExportToCellbrowser}: 6 | Write a big sparse matrix to a .tsv.gz file by writing chunks, concating them with the Unix cat command, 7 | then gziping the result. This does not work on Windows, we'd have to use the copy /b command there.} 8 | \usage{ 9 | writeSparseTsvChunks(inMat, outFname, sliceSize = 1000) 10 | } 11 | \arguments{ 12 | \item{inMat}{input matrix} 13 | 14 | \item{outFname}{output file name, has to end with .gz} 15 | 16 | \item{sliceSize=1000, }{size of each chunk in number of lines} 17 | } 18 | \value{ 19 | Invisibly returns \code{NULL} 20 | } 21 | \description{ 22 | Used by \code{ExportToCellbrowser}: 23 | Write a big sparse matrix to a .tsv.gz file by writing chunks, concating them with the Unix cat command, 24 | then gziping the result. This does not work on Windows, we'd have to use the copy /b command there. 25 | } 26 | \examples{ 27 | \dontrun{ 28 | writeSparseTsvChunks( pbmc_small@data, "exprMatrix.tsv.gz") 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /seurat-wrappers.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /test-vignettes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check changed vignettes for SeuratWrappers 4 | # Set global options to cause the script to fail upon failure of any one step 5 | set -eo pipefail 6 | 7 | # A simple function to get the extension of files 8 | function extension() { 9 | local fname="${1}" # Name of file to get extension of 10 | echo "$(echo ${fname} | rev | cut -f 1 -d '.' | rev)" 11 | } 12 | 13 | export -f extension 14 | 15 | # Get the remote for Satija Lab 16 | SATIJA_BRANCH="$(Rscript -e "cat(Seurat:::RandomName())")" 17 | (set -x; git fetch https://github.com/satijalab/seurat-wrappers +master:"${SATIJA_BRANCH}") 18 | 19 | # Get the branch for this PR 20 | PR_HASH="$(set -x; git log -n1 --format=format:'%H')" 21 | 22 | # Get differences between files 23 | declare -a DIFFS=($(set -x; git diff --name-only "${PR_HASH}" "${SATIJA_BRANCH}")) 24 | 25 | # Figure out which files have corresponding Rmds 26 | declare -a DIFF_RMDS=() 27 | declare -a MISSING=() 28 | for DFILE in ${DIFFS[@]}; do 29 | case $(dirname ${DFILE}) in # Only certain files will be checked 30 | docs) # Ensure we're only checking changed vignettes; these will have an extension of rmd or Rmd 31 | $(echo $(extension ${DFILE}) | grep -iw rmd > /dev/null 2> /dev/null) || continue 32 | DIFF_RMDS+=("${DFILE}") 33 | ;; 34 | R) # If a source file has changed, ensure it corresponds to a vignette 35 | if [[ $(basename ${DFILE}) == 'internal.R' ]]; then 36 | # If internal.R has changed, throw a warning for manual checks, but don't check everything on Azure 37 | echo "WARNING: internal.R has changed, please check all vignettes" >&2 38 | continue 39 | elif [[ $(echo $(extension ${DFILE}) | grep -iw r > /dev/null 2> /dev/null; echo "$?") -eq 0 ]]; then 40 | # If an R file has changed, ask if it has a vignette 41 | # If so, add the vignette to the list of vignettes to check 42 | # If not, put it in list of source files missing a vignette 43 | BNAME="$(basename ${DFILE} .$(extension ${DFILE}))" 44 | DVIGNETTE=$(find docs -maxdepth 1 -iregex "^docs/${BNAME}\.rmd") 45 | [[ "${#DVIGNETTE}" -eq 0 ]] && MISSING+=("${DFILE}") || DIFF_RMDS+=("${DVIGNETTE}") 46 | else 47 | # Non-R files shouldn't be here 48 | continue 49 | fi 50 | ;; 51 | *) # All other files are not checked 52 | continue 53 | ;; 54 | esac 55 | done 56 | 57 | # Do we have vignettes to check 58 | if [[ ${#DIFF_RMDS[@]} -eq 0 && ${#MISSING[@]} -gt 0 ]]; then 59 | # No, but source files changed, throw an error 60 | echo "ERROR: Missing vignettes for all changed source files" >&2 61 | exit 1 62 | elif [[ ${#MISSING[@]} -gt 0 ]]; then 63 | # Yes, but some source files changed and we couldn't find a vignette 64 | echo -e "WARNING: Missing vignettes for the following source files:" >&2 65 | for MV in ${MISSING[@]}; do echo -e "\t${MV}" >&2; done 66 | elif [[ ${#DIFF_RMDS[@]} -eq 0 ]]; then 67 | # No, and no source files changed 68 | echo "No changed vignettes" >&2 69 | exit 0 70 | else 71 | : 72 | fi 73 | 74 | # Store new vignettes in test-build dir 75 | mkdir test-build 76 | 77 | # Filter our changed vignettes list to only unique vignettes 78 | declare -a UNIQ_DIFFS=($(echo ${DIFF_RMDS[@]} | tr ' ' '\n' | sort | uniq)) 79 | for I in $(seq 1 ${#UNIQ_DIFFS[@]}); do 80 | TFILE="${UNIQ_DIFFS[$((${I} - 1))]}" 81 | echo "Testing vignette ${TFILE} (vignette ${I} of ${#UNIQ_DIFFS[@]})" >&2 82 | (set -x; Rscript -e "rmarkdown::render('${TFILE}', output_format = 'all', output_dir = 'test-build')") 83 | done 84 | --------------------------------------------------------------------------------