### Create Motif Object Example Source: https://stuartlab.org/signac/1.16.0/reference/createmotifobject An example demonstrating how to create a Motif object using CreateMotifObject with a sample motif matrix. ```r motif.matrix <- matrix( data = sample(c(0,1), size = 100, replace = TRUE), ncol = 5 ) rownames(motif.matrix) <- 1:nrow(motif.matrix) motif <- CreateMotifObject(data = motif.matrix) ``` -------------------------------- ### Install v2 Beta Release of Signac Source: https://stuartlab.org/signac/articles/install Installs the v2 beta release of Signac from its GitHub repository. Requires the 'remotes' package. ```r remotes::install_github("stuart-lab/signac", ref = "v2") ``` -------------------------------- ### CreateFragmentObject Example Source: https://stuartlab.org/signac/1.16.0/reference/createfragmentobject Example of creating a Fragment object. This demonstrates how to provide a path to a fragment file and a named character vector of cells. The verbose argument is set to FALSE to suppress messages. ```R fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac") cells <- colnames(x = atac_small) names(x = cells) <- paste0("test_", cells) frags <- CreateFragmentObject(path = fpath, cells = cells, verbose = FALSE, tolerance = 0.5) ``` -------------------------------- ### Install Development Version of Signac Source: https://stuartlab.org/signac/1.16.0/articles/install Installs the latest unreleased version of Signac directly from its GitHub repository using the 'remotes' package. Ensure 'remotes' is installed first. ```r if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes") remotes::install_github("stuart-lab/signac", ref = "develop") ``` -------------------------------- ### Install presto Package for Differential Analysis Source: https://stuartlab.org/signac/1.16.0/articles/pbmc_vignette Installs the 'presto' package from GitHub, which provides a fast implementation of the Wilcoxon rank-sum test for differential accessibility analysis. ```r if (!requireNamespace("remotes", quietly = TRUE)) install.packages('remotes') remotes::install_github('immunogenomics/presto') ``` -------------------------------- ### Example Usage of SubsetMatrix Source: https://stuartlab.org/signac/1.16.0/reference/subsetmatrix Demonstrates how to use the SubsetMatrix function with the 'volcano' dataset. This example applies default filtering criteria. ```R SubsetMatrix(mat = volcano) ``` -------------------------------- ### Get First Rows of a Fragment File Source: https://stuartlab.org/signac/1.16.0/reference/head.fragment Use the head.Fragment method to inspect the beginning of a fragment file. It returns a data frame with columns: chrom, start, end, barcode, readCount. ```R head(x, n = 6L, ...) ``` -------------------------------- ### Install Signac using Conda Source: https://stuartlab.org/signac/1.16.0/articles/install Installs Signac via conda, recommended for users who manage their R packages through conda. Ensure all R packages are installed via conda in this setup. ```bash conda install -c bioconda r-signac ``` -------------------------------- ### Install Cicero from GitHub Source: https://stuartlab.org/signac/1.16.0/articles/cicero Installs the Cicero package from a specific GitHub branch ('monocle3') if it's not already installed. This branch is required for compatibility with Monocle 3 CellDataSet objects. ```r # Install Cicero if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes") remotes::install_github("cole-trapnell-lab/cicero-release", ref = "monocle3") ``` -------------------------------- ### GetMotifData Example Source: https://stuartlab.org/signac/1.16.0/reference/getmotifdata This example demonstrates how to use the GetMotifData function with a small ATAC-seq dataset. The output is a sparse matrix indicating motif enrichment across genomic regions. ```R GetMotifData(object = atac_small) #> 323 x 10 sparse Matrix of class "dgCMatrix" #> [[ suppressing 10 column names 'MA0025.1', 'MA0030.1', 'MA0031.1' ... ]] #> #> chr1-713460-714823 . 1 . . 1 . . . . . #> chr1-752422-753038 . . . . . . . . . . #> chr1-762106-763359 . . . . 1 . . . . . #> chr1-779589-780271 . . . 1 . . . 1 1 . ``` -------------------------------- ### Example Usage of CreateMotifMatrix Source: https://stuartlab.org/signac/1.16.0/reference/createmotifmatrix Demonstrates how to create a motif matrix using CreateMotifMatrix with sample data. Requires JASPAR2018, TFBSTools, and BSgenome.Hsapiens.UCSC.hg19. ```r library(JASPAR2018) library(TFBSTools) library(BSgenome.Hsapiens.UCSC.hg19) pwm <- getMatrixSet( x = JASPAR2018, opts = list(species = 9606, all_versions = FALSE) ) motif.matrix <- CreateMotifMatrix( features = granges(atac_small), pwm = pwm, genome = BSgenome.Hsapiens.UCSC.hg19 ) ``` -------------------------------- ### Install Mouse mm10 Genome and Annotation Packages Source: https://stuartlab.org/signac/1.16.0/articles/install Installs the BSgenome and EnsDb packages for the mouse mm10 genome assembly and its corresponding gene annotation from Bioconductor. ```r BiocManager::install(c('BSgenome.Mmusculus.UCSC.mm10', 'EnsDb.Mmusculus.v79')) ``` -------------------------------- ### Install Human hg38 Genome and Annotation Packages Source: https://stuartlab.org/signac/1.16.0/articles/install Installs the BSgenome and EnsDb packages for the human hg38 genome assembly and its corresponding gene annotation from Bioconductor. ```r BiocManager::install(c('BSgenome.Hsapiens.UCSC.hg38', 'EnsDb.Hsapiens.v86')) ``` -------------------------------- ### BinarizeCounts Example with Matrix Source: https://stuartlab.org/signac/1.16.0/reference/binarizecounts Demonstrates how to use BinarizeCounts on a simple matrix. The function converts all counts greater than 1 to 1. ```r x <- matrix(data = sample(0:3, size = 25, replace = TRUE), ncol = 5) BinarizeCounts(x) #> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 0 1 1 1 #> [2,] 1 1 1 0 1 #> [3,] 1 1 1 0 1 #> [4,] 0 1 1 1 1 #> [5,] 0 0 1 0 1 ``` -------------------------------- ### FindTopFeatures Example Source: https://stuartlab.org/signac/1.16.0/reference/findtopfeatures Demonstrates how to use the FindTopFeatures function to identify top features from a dataset. The output shows the count and percentile for each feature. ```R FindTopFeatures(object = atac_small[['peaks']]['data']) #> count percentile #> chr1-2157847-2188813 384.21692 1.000000000 #> chr1-6843960-6846894 306.71972 0.996904025 #> chr1-3815928-3820356 293.92311 0.993808050 #> chr1-2471903-2481288 291.68103 0.990712074 #> chr1-2515241-2519350 273.54125 0.987616099 #> chr1-6051145-6055407 271.58079 0.984520124 #> chr1-6659264-6664388 269.06630 0.981424149 #> chr1-8935313-8940649 257.13518 0.978328173 #> chr1-1549446-1552535 249.25680 0.975232198 #> chr1-8020317-8022548 245.27406 0.972136223 #> chr1-1708510-1715065 238.85121 0.969040248 #> chr1-2322313-2323985 234.97422 0.965944272 #> chr1-3540009-3542500 226.59025 0.962848297 #> chr1-6672613-6675785 224.61335 0.959752322 #> chr1-2343197-2348396 223.27737 0.956656347 #> chr1-2486054-2489237 220.64562 0.953560372 #> chr1-6639159-6642773 220.03083 0.950464396 #> chr1-1051006-1053102 219.01926 0.947368421 #> chr1-1849693-1853920 216.86560 0.944272446 #> chr1-6085254-6089147 209.43368 0.941176471 #> chr1-2063672-2065744 208.40462 0.938080495 #> chr1-1240091-1245762 202.41066 0.934984520 #> chr1-1309645-1311492 200.93170 0.931888545 #> chr1-1333514-1336003 199.69752 0.928792570 #> chr1-1819732-1824104 199.57829 0.925696594 #> chr1-2135022-2137621 198.43822 0.922600619 #> chr1-928630-937949 195.69880 0.919504644 #> chr1-6452328-6454679 194.68799 0.916408669 #> chr1-1839727-1841458 192.45257 0.913312693 #> chr1-7830534-7832331 191.47613 0.910216718 #> chr1-9293115-9295644 188.43304 0.907120743 #> chr1-2125466-2127403 188.28612 0.904024768 #> chr1-7841489-7844891 180.48141 0.900928793 #> chr1-2456987-2458884 178.90723 0.897832817 #> chr1-1446312-1448163 177.61112 0.894736842 #> chr1-9188154-9190941 176.17157 0.891640867 #> chr1-1655226-1656410 175.89464 0.888544892 #> chr1-713460-714823 175.20779 0.885448916 #> chr1-1259506-1261414 172.88999 0.882352941 #> chr1-3773000-3774956 170.91511 0.879256966 #> chr1-1166366-1168282 169.69997 0.876160991 #> chr1-1623610-1625141 167.78231 0.873065015 #> chr1-1341794-1343522 166.82518 0.869969040 #> chr1-1562519-1567986 165.90765 0.866873065 #> chr1-2227715-2234197 163.94501 0.863777090 #> chr1-894021-896898 163.92453 0.860681115 #> chr1-2241757-2247855 162.95554 0.857585139 #> chr1-8876634-8878709 158.30708 0.854489164 #> chr1-6258846-6260407 155.41484 0.851393189 #> chr1-8013637-8014963 153.16873 0.848297214 #> chr1-1509089-1511050 152.49880 0.845201238 #> chr1-1980856-1982929 152.22569 0.842105263 #> chr1-7763862-7766072 150.39382 0.839009288 #> chr1-2573495-2575472 146.91583 0.835913313 #> chr1-954372-958413 144.81406 0.832817337 #> chr1-8584964-8586531 144.25964 0.829721362 #> chr1-2507261-2510518 142.61074 0.826625387 #> chr1-2130011-2131484 141.84665 0.823529412 #> chr1-6613890-6615140 141.29329 0.820433437 #> chr1-2221250-2223390 137.61758 0.817337461 #> chr1-1406028-1408272 137.55682 0.814241486 #> chr1-1283373-1285555 136.39638 0.811145511 #> chr1-8085460-8087248 135.60007 0.808049536 #> chr1-1207999-1210168 134.51559 0.804953560 #> chr1-6684553-6686243 129.16952 0.801857585 #> chr1-1002063-1006231 128.99640 0.798761610 #> chr1-1589986-1591117 126.80636 0.795665635 #> chr1-6761132-6762608 126.40764 0.792569659 #> chr1-994056-995654 125.59260 0.789473684 #> chr1-973840-977754 124.71487 0.786377709 #> chr1-762106-763359 123.17802 0.783281734 #> chr1-948133-951142 122.24861 0.780185759 #> chr1-3712392-3713775 121.80754 0.777089783 #> chr1-2120455-212065 116.93195 0.773993808 #> chr1-1306174-1308201 113.16641 0.770897833 #> chr1-2082091-2083429 112.73853 0.767801858 #> chr1-3565942-3569718 110.18451 0.764705882 #> chr1-3688192-3690359 109.72059 0.761609907 #> chr1-2143708-2144981 108.88198 0.758513932 #> chr1-1147592-1153647 105.88473 0.755417957 #> chr1-1135873-1137356 105.68426 0.752321981 #> chr1-8482480-8485295 104.61046 0.749226006 #> chr1-6319594-6322140 103.52703 0.746130031 #> chr1-6295272-6296706 100.78740 0.743034056 #> chr1-1092026-1094240 100.73212 0.739938080 #> chr1-3535177-3536355 100.46039 0.736842105 #> chr1-8000672-8003534 99.37711 0.733746130 #> chr1-967806-970136 88.56877 0.730650155 #> chr1-9352328-9354391 86.97476 0.727554180 #> chr1-8762907-8763964 86.29183 0.724458204 #> chr1-6304964-6307369 84.12494 0.721362229 #> chr1-998895-1000200 82.58409 0.718266254 #> chr1-1140204-1144858 82.27853 0.715170279 #> chr1-1057192-1058404 82.26495 0.712074303 #> chr1-1695549-1696821 80.78735 0.708978328 #> chr1-3662633-3664352 74.64851 0.705882353 #> chr1-6418151-6420435 73.54881 0.702786378 #> chr1-8487258-8488478 73.21975 0.699690402 #> chr1-6187544-6188439 72.91401 0.696594427 #> chr1-901313-902847 72.70957 0.693498452 #> chr1-2454600-2456271 72.68043 0.690402477 #> chr1-1534779-1536172 72.49716 0.687306502 #> chr1-3446985-3448712 72.11667 0.684210526 #> chr1-8186838-8187845 71.40895 0.681114551 #> chr1-1800682-1801583 71.11832 0.678018576 #> chr1-2079917-2080950 68.57285 0.674922601 ``` -------------------------------- ### Example: Run chromVAR on Seurat Object Source: https://stuartlab.org/signac/1.16.0/reference/runchromvar Example of running RunChromVAR directly on a Seurat object, specifying the human genome build. This requires the BSgenome.Hsapiens.UCSC.hg19 package. ```R library(BSgenome.Hsapiens.UCSC.hg19) RunChromVAR(object = atac_small, genome = BSgenome.Hsapiens.UCSC.hg19) ``` -------------------------------- ### Download 10x Multiome Data Source: https://stuartlab.org/signac/1.16.0/articles/pbmc_multiomic Download the necessary data files for the 10x multiomic dataset. Ensure you have wget installed. ```shell wget https://cf.10xgenomics.com/samples/cell-arc/1.0.0/pbmc_granulocyte_sorted_10k/pbmc_granulocyte_sorted_10k_filtered_feature_bc_matrix.h5 wget https://cf.10xgenomics.com/samples/cell-arc/1.0.0/pbmc_granulocyte_sorted_10k/pbmc_granulocyte_sorted_10k_atac_fragments.tsv.gz wget https://cf.10xgenomics.com/samples/cell-arc/1.0.0/pbmc_granulocyte_sorted_10k/pbmc_granulocyte_sorted_10k_atac_fragments.tsv.gz.tbi ``` -------------------------------- ### Example Usage of MotifPlot Source: https://stuartlab.org/signac/1.16.0/reference/motifplot Demonstrates how to use MotifPlot to visualize motifs from a Seurat object. Ensure the 'atac_small' object and 'Motifs' function are available. ```r # \donttest{ motif.obj <- Motifs(atac_small) MotifPlot(atac_small, motifs = head(colnames(motif.obj))) #> Warning: The `` argument of `guides()` cannot be `FALSE`. Use "none" instead as #> of ggplot2 3.3.4. #> ℹ The deprecated feature was likely used in the ggseqlogo package. #> Please report the issue at . # } ``` -------------------------------- ### Example: Creating and Assigning Fragment Objects Source: https://stuartlab.org/signac/reference/fragments Shows how to create a Fragment object from a file path and assign it to an assay or the entire Seurat object. Ensure the path to the fragment file is correct and that cell information is provided. ```R fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac") fragments <- CreateFragmentObject( path = fpath, cells = colnames(atac_small), validate.fragments = FALSE ) #> Computing hash Fragments(atac_small, ...)[["bins"]] <- fragments fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac") fragments <- CreateFragmentObject( path = fpath, cells = colnames(atac_small), validate.fragments = FALSE ) #> Computing hash Fragments(atac_small) <- fragments ``` -------------------------------- ### Get Gene Coordinates Example Source: https://stuartlab.org/signac/1.16.0/reference/lookupgenecoords Example of using LookupGeneCoords to find the coordinates for a specific gene within a Seurat object. Ensure the 'atac_small' object and the 'MIR1302-10' gene are available in your environment. ```r LookupGeneCoords(atac_small, gene = "MIR1302-10") #> GRanges object with 1 range and 0 metadata columns: #> seqnames ranges strand #> #> [1] chr1 29554-31109 * #> ------- #> seqinfo: 1 sequence from an unspecified genome; no seqlengths ``` -------------------------------- ### Set up Parallel Processing with 4 Cores Source: https://stuartlab.org/signac/articles/future Initializes the 'future' package to use 4 parallel workers. It also sets a global option for the maximum size of future globals. This setup is used for the first set of timing measurements. ```R library(future) plan("multicore", workers = 4) options(future.globals.maxSize = 100000 * 1024^2) ``` -------------------------------- ### Downloading benchmarking data Source: https://stuartlab.org/signac/articles/future These commands download the necessary data files for benchmarking the FeatureMatrix function. Ensure you have wget installed and sufficient disk space. ```bash # download data wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz.tbi wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_peaks.bed wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_singlecell.csv ``` -------------------------------- ### Example Usage of GetCellsInRegion Source: https://stuartlab.org/signac/1.16.0/reference/getcellsinregion Demonstrates how to use GetCellsInRegion to extract cell names from a fragments file for a specified genomic region. Ensure the 'Signac' package is installed and the fragments file path is correctly set. ```R fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac") GetCellsInRegion(tabix = fpath, region = "chr1-10245-762629") #> $`chr1:10245-762629` #> [1] "AAAGATGAGGCTAAAT-1" "AAACTCGTCTGGCACG-1" "AAACTCGTCTGGCACG-1" #> [4] "AAACTGCAGTCTGTGT-1" "AAACTGCTCCTATCCG-1" "AAAGGATTCCTTACGC-1" #> [7] "AAAGATGAGAAGGGCG-1" "AAACGAAGTGCCCGAT-1" "AAACTGCAGTCTGTGT-1" #> [10] "AAACGAAAGGCTTCGC-1" "AAACTCGCAGCGTCGT-1" "AAACGAAGTGCCCGAT-1" #> [13] "AAACGAATCCTTACGC-1" "AAAGGATCATGGAGGT-1" "AAACTGCTCCTATCCG-1" #> [16] "AAAGATGCACGTTACA-1" "AAAGATGTCCACACCT-1" "AAACGAAAGGCTTCGC-1" #> [19] "AAACTGCAGAATCAAC-1" "AAACTCGGTTTGATCG-1" "AAAGATGCAAGTCTGT-1" #> [22] "AAACTCGTCAGGTCTA-1" "AAACGAAAGGCTTCGC-1" "AAACTGCGTGCATTCA-1" #> [25] "AAACTGCTCCTATCCG-1" "AAACTGCCATGTATCG-1" "AAAGGATTCCTTACGC-1" #> [28] "AAACTGCCAAGCCAGA-1" "AAACTCGAGTACTCTG-1" "AAACTGCTCGTTCAGA-1" #> [31] "AAAGGATGTCGTAATC-1" "AAAGGATTCCTTACGC-1" "AAACGAAGTCAGGCTC-1" #> [34] "AAACTGCAGCTCCATA-1" "AAAGATGAGTCCAGAG-1" "AAAGATGTCCACACCT-1" #> [37] "AAAGATGTCCACACCT-1" "AAACTGCTCATTCATC-1" "AAACGAAAGCGAGCTA-1" #> [40] "AAACTCGGTGGATTCT-1" "AAACGAAAGGCTTCGC-1" "AAACTCGTCTGGCACG-1" #> [43] "AAAGATGTCTAGCAGT-1" "AAAGGATCAGATGGCA-1" "AAACTGCGTACTAGAA-1" #> [46] "AAACGAAAGGCTTCGC-1" "AAAGATGAGGCTAAAT-1" "AAAGATGAGGCTAAAT-1" #> [49] "AAACTCGAGTACTCTG-1" "AAAGATGTCCTGAAAC-1" "AAAGGATCAAGGGAGG-1" #> [52] "AAAGATGCAGCACATT-1" "AAACTCGGTTTGATCG-1" "AAACTCGGTGGATTCT-1" #> [55] "AAACTCGCAAAGAGAG-1" "AAAGATGAGTCGACCC-1" "AAACTCGCATCACAGT-1" #> [58] "AAAGGATTCTATGAGC-1" "AAAGGATGTCCCTTTG-1" "AAACTGCCAACAAACA-1" #> [61] "AAAGATGCATGACTGT-1" "AAAGATGAGAAGGGCG-1" "AAACTCGTCCACTAGA-1" #> [64] "AAAGATGCACGTTACA-1" "AAAGATGCAGCGTCGT-1" "AAACGAAAGGCTTCGC-1" #> [67] "AAAGGATGTCTAAGAA-1" "AAACGAAGTTGTATCG-1" "AAAGGATAGAACCATA-1" #> [70] "AAACTCGCATGTGGGA-1" #> ``` -------------------------------- ### Example: Accessing Fragments from an Assay Source: https://stuartlab.org/signac/reference/fragments Demonstrates how to get fragment objects associated with a specific assay (e.g., 'peaks') within a Seurat object. This is useful for inspecting the fragments linked to a particular data modality. ```R Fragments(atac_small, ...) #> list() Fragments(atac_small, ...) #> list() ``` -------------------------------- ### Get Cells in Region Example Source: https://stuartlab.org/signac/reference/getcellsinregion Demonstrates how to use GetCellsInRegion to extract cell names that have reads within a specific genomic region. Requires a Tabix object and a region string. The output is a list where keys are regions and values are vectors of cell names. ```R fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac") GetCellsInRegion(tabix = fpath, region = "chr1-10245-762629") #> $`chr1:10245-762629` #> [1] "AAAGATGAGGCTAAAT-1" "AAACTCGTCTGGCACG-1" "AAACTCGTCTGGCACG-1" #> [4] "AAACTGCAGTCTGTGT-1" "AAACTGCTCCTATCCG-1" "AAAGGATTCCTTACGC-1" #> [7] "AAAGATGAGAAGGGCG-1" "AAACGAAGTGCCCGAT-1" "AAACTGCAGTCTGTGT-1" #> [10] "AAACGAAAGGCTTCGC-1" "AAACTCGCAGCGTCGT-1" "AAACGAAGTGCCCGAT-1" #> [13] "AAACGAATCCTTACGC-1" "AAAGGATCATGGAGGT-1" "AAACTGCTCCTATCCG-1" #> [16] "AAAGATGCACGTTACA-1" "AAAGATGTCCACACCT-1" "AAACGAAAGGCTTCGC-1" #> [19] "AAACTGCAGAATCAAC-1" "AAACTCGGTTTGATCG-1" "AAAGATGTCAAGTCTGT-1" #> [22] "AAACTCGTCAGGTCTA-1" "AAACGAAAGGCTTCGC-1" "AAACTGCGTGCATTCA-1" #> [25] "AAACTGCTCCTATCCG-1" "AAACTGCCATGTATCG-1" "AAAGGATTCCTTACGC-1" #> [28] "AAACTGCCAAGCCAGA-1" "AAACTCGAGTACTCTG-1" "AAACTGCTCGTTCAGA-1" #> [31] "AAAGGATGTCGTAATC-1" "AAAGGATTCCTATGAGC-1" "AAACGAAGTCAGGCTC-1" #> [34] "AAACTGCAGCTCCATA-1" "AAAGATGAGTCCAGAG-1" "AAAGATGTCCACACCT-1" #> [37] "AAAGATGTCCACACCT-1" "AAACTGCTCATTCATC-1" "AAACGAAAGCGAGCTA-1" #> [40] "AAACTCGGTGGATTCT-1" "AAACGAAAGGCTTCGC-1" "AAACTCGTCTGGCACG-1" #> [43] "AAAGATGTCTAGCAGT-1" "AAAGGATCAGATGGCA-1" "AAACTGCGTACTAGAA-1" #> [46] "AAACGAAAGGCTTCGC-1" "AAAGATGAGGCTAAAT-1" "AAAGATGAGGCTAAAT-1" #> [49] "AAACTCGAGTACTCTG-1" "AAAGATGTCCTGAAAC-1" "AAAGGATCAAGGGAGG-1" #> [52] "AAAGATGCAGCACATT-1" "AAACTCGGTTTGATCG-1" "AAACTCGGTGGATTCT-1" #> [55] "AAACTCGCAAAGAGAG-1" "AAAGATGAGTCGACCC-1" "AAACTCGCATCACAGT-1" #> [58] "AAAGGATTCTATGAGC-1" "AAAGGATGTCCCTTTG-1" "AAACTGCCAACAAACA-1" #> [61] "AAAGATGCATGACTGT-1" "AAAGATGAGAAGGGCG-1" "AAACTCGTCCACTAGA-1" #> [64] "AAAGATGCACGTTACA-1" "AAAGATGCAGCGTCGT-1" "AAACGAAAGGCTTCGC-1" #> [67] "AAAGGATGTCTAAGAA-1" "AAACGAAGTTGTATCG-1" "AAAGGATAGAACCATA-1" #> [70] "AAACTCGCATGTGGGA-1" #> ``` -------------------------------- ### Call Peaks with Custom MACS2 Path and Output Directory Source: https://stuartlab.org/signac/1.16.0/reference/callpeaks This example specifies a custom path to the MACS2 executable and a custom output directory for the peak calling results. Ensure the provided 'macs2.path' is correct. ```R pbmc <- CallPeaks(pbmc, macs2.path = "/path/to/macs2", outdir = "/path/to/output") ``` -------------------------------- ### Initialize ChromatinAssay with Fragment Path Source: https://stuartlab.org/signac/1.16.0/articles/data_structures Creates a ChromatinAssay by directly providing the path to a fragment file. Assumes the file contains fragments for all cells in the assay and cell names match. ```R chrom_assay <- CreateChromatinAssay( counts = counts, genome = "hg19", fragments = frag.path ) ``` -------------------------------- ### Call Peaks using Fragment File Path Source: https://stuartlab.org/signac/1.16.0/reference/callpeaks This example demonstrates calling peaks by providing the path to a fragment file. The function will process the specified fragment file to identify peaks. ```R peaks <- CallPeaks("path/to/fragments.tsv.gz") ``` -------------------------------- ### Set up Parallel Processing with 10 Cores Source: https://stuartlab.org/signac/articles/future Reconfigures the 'future' package to use 10 parallel workers. This is done to compare performance against the previous 4-core setup. ```R plan("multicore", workers = 10) ``` -------------------------------- ### Setting up and running FeatureMatrix sequentially Source: https://stuartlab.org/signac/articles/future This R code block demonstrates how to load Signac, create a Fragment object, and then run the FeatureMatrix function sequentially for benchmarking purposes. It measures the time taken for multiple replicates. ```r library(Signac) # load data fragments <- "../vignette_data/atac_pbmc_10k_nextgem_fragments.tsv.gz" peaks.10k <- read.table( file = "../vignette_data/atac_pbmc_10k_nextgem_peaks.bed", col.names = c("chr", "start", "end") ) peaks <- GenomicRanges::makeGRangesFromDataFrame(peaks.10k) md <- read.csv("../vignette_data/atac_pbmc_10k_nextgem_singlecell.csv", row.names = 1, header = TRUE)[-1, ] cells <- rownames(md[md[['is__cell_barcode']] == 1, ]) fragments <- CreateFragmentObject(path = fragments, cells = cells, validate.fragments = FALSE) # set number of replicates nrep <- 5 results <- data.frame() process_n <- 2000 # run sequentially timing.sequential <- c() for (i in seq_len(nrep)) { start <- Sys.time() fmat <- FeatureMatrix(fragments = fragments, features = peaks, cells = cells, process_n = process_n) timing.sequential <- c(timing.sequential, as.numeric(Sys.time() - start, units = "secs")) } res <- data.frame( "setting" = rep("Sequential", nrep), "cores" = rep(1, nrep), "replicate" = seq_len(nrep), "time" = timing.sequential ) results <- rbind(results, res) ``` -------------------------------- ### Install Current Release of Signac Source: https://stuartlab.org/signac/1.16.0/articles/install Installs the latest stable version of Signac from CRAN. Requires setting repositories to include Bioconductor dependencies. ```r setRepositories(ind=1:3) # needed to automatically install Bioconductor dependencies install.packages("Signac") ``` -------------------------------- ### Example Usage of MatchRegionStats Source: https://stuartlab.org/signac/1.16.0/reference/matchregionstats Demonstrates how to use the MatchRegionStats function with sample data. It matches regions based on the 'percentile' feature and selects 10 regions. ```R metafeatures <- SeuratObject::GetAssayData( object = atac_small[['peaks']], layer = 'meta.features' ) query.feature <- metafeatures[1:10, ] features.choose <- metafeatures[11:nrow(metafeatures), ] MatchRegionStats( meta.feature = features.choose, query.feature = query.feature, features.match = "percentile", n = 10 ) ``` -------------------------------- ### Example Usage of AnnotationPlot Source: https://stuartlab.org/signac/1.16.0/reference/annotationplot Demonstrates how to use AnnotationPlot with a Seurat object and a specified genomic region. This example plots gene annotations for a given region. ```r # \donttest{ AnnotationPlot(object = atac_small, region = c("chr1-29554-39554")) # > Warning: `aes_string()` was deprecated in ggplot2 3.0.0. # > ℹ Please use tidy evaluation idioms with `aes()`. # > ℹ See also `vignette("ggplot2-in-packages")` for more information. # > ℹ The deprecated feature was likely used in the Signac package. # > Please report the issue at . # > Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. # > ℹ Please use `linewidth` instead. # > ℹ The deprecated feature was likely used in the Signac package. # > Please report the issue at . # } ``` -------------------------------- ### Load Signac and ggplot2, and load PBMC dataset Source: https://stuartlab.org/signac/1.16.0/articles/visualization Load the necessary libraries and the PBMC dataset for visualization. Ensure the 'pbmc.qs2' file is accessible. ```r library(Signac) library(ggplot2) # load PBMC dataset pbmc <- qs2::qs_read("pbmc.qs2") ``` -------------------------------- ### R Session Information Details Source: https://stuartlab.org/signac/articles/visualization Provides a detailed breakdown of the R environment, including base packages, attached packages, and loaded namespaces, along with their versions. ```text ## R version 4.5.1 (2025-06-13) ## Platform: aarch64-apple-darwin20 ## Running under: macOS Tahoe 26.4 ## ## Matrix products: default ## BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib ## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1 ## ## locale: ## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 ## ## time zone: Asia/Singapore ## tzcode source: internal ## ## attached base packages: ## [1] stats4 stats graphics grDevices utils datasets methods ## [8] base ## ## other attached packages: ## [1] GenomicRanges_1.62.1 Seqinfo_1.0.0 IRanges_2.44.0 ## [4] S4Vectors_0.48.0 BiocGenerics_0.56.0 generics_0.1.4 ## [7] ggplot2_4.0.2 Signac_1.17.0 ## ## loaded via a namespace (and not attached): ## [1] tidyselect_1.2.1 dplyr_1.2.0 farver_2.1.2 ## [4] Biostrings_2.78.0 S7_0.2.1 bitops_1.0-9 ## [7] fastmap_1.2.0 tweenr_2.0.3 stringfish_0.18.0 ## [10] digest_0.6.39 dotCall64_1.2 lifecycle_1.0.5 ``` -------------------------------- ### Create and Assign Fragment Objects Source: https://stuartlab.org/signac/1.16.0/reference/fragments Create a Fragment object from a file path and assign it to an assay or the Seurat object. Ensure the path to the fragments file is correctly specified. ```r fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac") fragments <- CreateFragmentObject( path = fpath, cells = colnames(atac_small), validate.fragments = FALSE ) #> Computing hash Fragments(atac_small[["bins"]]) <- fragments ``` ```r fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac") fragments <- CreateFragmentObject( path = fpath, cells = colnames(atac_small), validate.fragments = FALSE ) #> Computing hash Fragments(atac_small) <- fragments ``` -------------------------------- ### Install Human hg19 Genome and Annotation Packages Source: https://stuartlab.org/signac/1.16.0/articles/install Installs the BSgenome and EnsDb packages for the human hg19 genome assembly and its corresponding gene annotation from Bioconductor. ```r BiocManager::install(c('BSgenome.Hsapiens.UCSC.hg19', 'EnsDb.Hsapiens.v75')) ``` -------------------------------- ### Download benchmarking data Source: https://stuartlab.org/signac/1.16.0/articles/future Download necessary data files for benchmarking Signac functions. These files include fragment information, peak locations, and single-cell metadata. ```bash wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz.tbi wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_peaks.bed wget https://cf.10xgenomics.com/samples/cell-atac/2.0.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_singlecell.csv ``` -------------------------------- ### Downsample Features Example Source: https://stuartlab.org/signac/reference/downsamplefeatures Demonstrates how to use the DownsampleFeatures function to randomly downsample features from a Seurat object. This example sets the number of features to retain to 10. ```r DownsampleFeatures(atac_small, n = 10) ``` -------------------------------- ### List Fragment Class Methods Source: https://stuartlab.org/signac/1.16.0/articles/data_structures Displays all available methods for the 'Fragment' class in R, useful for exploring its functionality. ```R methods(class = 'Fragment') ``` -------------------------------- ### Install Older Signac Releases Source: https://stuartlab.org/signac/1.16.0/articles/install Installs a specific older version of Signac from the CRAN archive using the 'remotes' package. Replace '0.2.5' with the desired version number. ```r if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes") # replace "0.2.5" with the version that you want to install remotes::install_version(package = 'Signac', version = package_version('0.2.5')) ``` -------------------------------- ### Download TF1 Dataset Files Source: https://stuartlab.org/signac/1.16.0/articles/mito Download ATAC and mitochondrial genome data files from Zenodo using wget. ```bash # ATAC data wget https://zenodo.org/record/3977808/files/TF1.filtered.fragments.tsv.gz wget https://zenodo.org/record/3977808/files/TF1.filtered.fragments.tsv.gz.tbi wget https://zenodo.org/record/3977808/files/TF1.filtered.narrowPeak.gz # mitochondrial genome data wget https://zenodo.org/record/3977808/files/TF1_filtered.A.txt.gz wget https://zenodo.org/record/3977808/files/TF1_filtered.T.txt.gz wget https://zenodo.org/record/3977808/files/TF1_filtered.C.txt.gz wget https://zenodo.org/record/3977808/files/TF1_filtered.G.txt.gz wget https://zenodo.org/record/3977808/files/TF1_filtered.chrM_refAllele.txt.gz wget https://zenodo.org/record/3977808/files/TF1_filtered.depthTable.txt.gz ```