Skip to content

Commit 458e647

Browse files
committed
Merge branch 'develop'
2 parents 63d61be + 8a17721 commit 458e647

30 files changed

+1928
-628
lines changed

.github/workflows/cmd-check.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ env:
3838
run_covr: 'false'
3939
run_pkgdown: 'false'
4040
has_RUnit: 'false'
41-
cache-version: 'cache-v1'
41+
cache-version: 'cache-v3'
4242
run_docker: 'false'
4343

4444
jobs:
@@ -54,7 +54,7 @@ jobs:
5454
fail-fast: false
5555
matrix:
5656
config:
57-
- { os: ubuntu-latest, r: '4.0', bioc: '3.12', cont: "bioconductor/bioconductor_docker:RELEASE_3_12", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
57+
- { os: ubuntu-latest, r: '4.1', bioc: '3.14', cont: "bioconductor/bioconductor_docker:RELEASE_3_14", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
5858

5959
env:
6060
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true

DESCRIPTION

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Signac
22
Title: Analysis of Single-Cell Chromatin Data
3-
Version: 1.5.0
4-
Date: 2021-12-07
3+
Version: 1.6.0
4+
Date: 2022-03-04
55
Authors@R: c(
66
person(given = 'Tim', family = 'Stuart', email = '[email protected]', role = c('aut', 'cre'), comment = c(ORCID = '0000-0002-3044-0897')),
77
person(given = 'Avi', family = 'Srivastava', email = '[email protected]', role = 'aut', comment = c(ORCID = '0000-0001-9798-2079')),
@@ -30,7 +30,7 @@ Imports:
3030
Matrix,
3131
Rsamtools,
3232
S4Vectors,
33-
Seurat (>= 4.0.0),
33+
Seurat (>= 4.0.6),
3434
SeuratObject (>= 4.0.0),
3535
data.table,
3636
dplyr (>= 1.0.0),
@@ -54,7 +54,8 @@ Imports:
5454
Rcpp,
5555
ggforce,
5656
qlcMatrix,
57-
grid
57+
grid,
58+
tidyselect
5859
Collate:
5960
'RcppExports.R'
6061
'data.R'
@@ -65,6 +66,7 @@ Collate:
6566
'fragments.R'
6667
'genomeinfodb-methods.R'
6768
'granges-methods.R'
69+
'heatmaps.R'
6870
'iranges-methods.R'
6971
'links.R'
7072
'mito.R'
@@ -73,6 +75,7 @@ Collate:
7375
'peaks.R'
7476
'preprocessing.R'
7577
'quantification.R'
78+
'region-enrichment.R'
7679
'utilities.R'
7780
'visualization.R'
7881
'zzz.R'

NAMESPACE

+11
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ S3method(Links,ChromatinAssay)
5454
S3method(Links,Seurat)
5555
S3method(Motifs,ChromatinAssay)
5656
S3method(Motifs,Seurat)
57+
S3method(RegionMatrix,ChromatinAssay)
58+
S3method(RegionMatrix,Seurat)
59+
S3method(RegionMatrix,default)
5760
S3method(RegionStats,ChromatinAssay)
5861
S3method(RegionStats,Seurat)
5962
S3method(RegionStats,default)
@@ -145,12 +148,16 @@ export(LinkPlot)
145148
export(Links)
146149
export(LookupGeneCoords)
147150
export(MatchRegionStats)
151+
export(MotifCounts)
148152
export(MotifPlot)
149153
export(Motifs)
150154
export(NucleosomeSignal)
151155
export(PeakPlot)
152156
export(PlotFootprint)
153157
export(ReadMGATK)
158+
export(RegionHeatmap)
159+
export(RegionMatrix)
160+
export(RegionPlot)
154161
export(RegionStats)
155162
export(RunChromVAR)
156163
export(RunSVD)
@@ -303,6 +310,7 @@ importFrom(Seurat,Project)
303310
importFrom(Seurat,RenameCells)
304311
importFrom(Seurat,RowMergeSparseMatrices)
305312
importFrom(Seurat,SetAssayData)
313+
importFrom(Seurat,SetQuantile)
306314
importFrom(Seurat,VariableFeatures)
307315
importFrom(Seurat,WhichCells)
308316
importFrom(SeuratObject,Cells)
@@ -340,9 +348,11 @@ importFrom(ggplot2,guide_legend)
340348
importFrom(ggplot2,guides)
341349
importFrom(ggplot2,labs)
342350
importFrom(ggplot2,scale_color_gradient2)
351+
importFrom(ggplot2,scale_color_grey)
343352
importFrom(ggplot2,scale_color_identity)
344353
importFrom(ggplot2,scale_color_manual)
345354
importFrom(ggplot2,scale_fill_gradient)
355+
importFrom(ggplot2,scale_fill_grey)
346356
importFrom(ggplot2,scale_fill_manual)
347357
importFrom(ggplot2,scale_fill_viridis_c)
348358
importFrom(ggplot2,scale_x_continuous)
@@ -393,6 +403,7 @@ importFrom(stats,sd)
393403
importFrom(stringi,stri_split_fixed)
394404
importFrom(tidyr,pivot_longer)
395405
importFrom(tidyr,separate)
406+
importFrom(tidyselect,all_of)
396407
importFrom(tools,file_ext)
397408
importFrom(tools,md5sum)
398409
importFrom(utils,globalVariables)

NEWS.md

+28
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# Signac 1.6.0
2+
3+
New functionality:
4+
5+
* Added `RegionHeatmap()` function
6+
* Added `RegionPlot()` function
7+
* Added `RegionMatrix()` function
8+
* Added `MotifCounts()` function
9+
* Added ability to plot multiple assays simultaneously in `CoveragePlot()` by providing a list of assay names
10+
* Added `assay.scale`, `bigwig.scale`, and `split.assay` parameters to `CoveragePlot()`
11+
* Added new option to provide quantile `ymax` value in `CoveragePlot()`
12+
* Added `bigwig.scale` and `ymax` parameters to `BigwigTrack()`
13+
* Added `peak.slot` parameter to `LinkPeaks()` ([#932](https://github.com/timoast/signac/issues/932))
14+
15+
Bug fixes:
16+
17+
* Fixed behaviour of `min.features` parameter in `CreateChromatinAssay()` to retain cells with `>= min.features` (#[902](https://github.com/timoast/signac/discussions/902))
18+
* Fixed behaviour of `min.cells` parameter in `LinkPeaks()` ([#932](https://github.com/timoast/signac/issues/932))
19+
20+
Other changes:
21+
22+
* Updated documentation for `CoveragePlot()` ([#992](https://github.com/timoast/signac/issues/992))
23+
* Removed `method` parameter from `LinkPeaks()` ([#932](https://github.com/timoast/signac/issues/932))
24+
125
# Signac 1.5.0
226

327
Bug fixes:
@@ -17,6 +41,10 @@ Other changes:
1741

1842
# Signac 1.4.0
1943

44+
New functionality:
45+
46+
* Added ability to display multiple assays in `CoveragePlot()`. The `assay` parameter can now be a list of assays to plot data from, with signal colored by assay of origin.
47+
2048
Bug fixes:
2149

2250
* Fixed bug in `FindMotifs()` when using only one region as input ([#732](https://github.com/timoast/signac/issues/732))

R/footprinting.R

+7-7
Original file line numberDiff line numberDiff line change
@@ -495,27 +495,27 @@ RunFootprint <- function(
495495
if (verbose) {
496496
message("Computing observed Tn5 insertions per base")
497497
}
498+
dna.sequence <- Biostrings::getSeq(x = genome, Extend(
499+
x = regions,
500+
upstream = 3,
501+
downstream = 3
502+
)
503+
)
498504
if (compute.expected) {
499505
bias <- GetAssayData(object = object, slot = "bias")
500506
if (is.null(x = bias)) {
501507
stop("Insertion bias not computed")
502508
} else {
503509
# add three bases each side here so we can get the hexamer frequencies
504510
# for every position
505-
dna.sequence <- Biostrings::getSeq(x = genome, Extend(
506-
x = regions,
507-
upstream = 3,
508-
downstream = 3
509-
)
510-
)
511511
expected.insertions <- FindExpectedInsertions(
512512
dna.sequence = dna.sequence,
513513
bias = bias,
514514
verbose = verbose
515515
)
516516
}
517517
} else {
518-
expected.insertions <- rep(1, width(x = dna.sequence)[[1]])
518+
expected.insertions <- rep(1, width(x = dna.sequence)[[1]] - 6)
519519
}
520520

521521
# count insertions at each position for each cell

R/fragments.R

+48-16
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ head.Fragment <- function(x, n = 6L, ...) {
3232
#'
3333
#' Count total fragments per cell barcode present in a fragment file.
3434
#'
35-
#' @param fragments Path to a fragment file
35+
#' @param fragments Path to a fragment file. If a list of fragment files is
36+
#' provided, the total fragments for each cell barcode across all files will be
37+
#' returned
3638
#' @param cells Cells to include. If NULL, include all cells
3739
#' @param max_lines Maximum number of lines to read from the fragment file. If
3840
#' NULL, read all lines in the file.
@@ -41,7 +43,14 @@ head.Fragment <- function(x, n = 6L, ...) {
4143
#' @rdname CountFragments
4244
#' @export
4345
#' @concept fragments
44-
#' @return Returns a data.frame
46+
#' @return Returns a data.frame with the following columns:
47+
#' \itemize{
48+
#' \item{CB: the cell barcode}
49+
#' \item{frequency_count: total number of fragments sequenced for the cell}
50+
#' \item{mononucleosome: total number of fragments with length between 147 bp and 294 bp}
51+
#' \item{nucleosome_free: total number of fragments with length <147 bp}
52+
#' \item{reads_count: total number of reads sequenced for the cell}
53+
#' }
4554
#' @examples
4655
#' fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac")
4756
#' counts <- CountFragments(fragments = fpath)
@@ -51,22 +60,45 @@ CountFragments <- function(
5160
max_lines = NULL,
5261
verbose = TRUE
5362
) {
54-
if (isRemote(x = fragments)) {
55-
stop("Remote fragment files not supported")
63+
if (!inherits(x = fragments, what = "list")) {
64+
fragments <- list(fragments)
5665
}
57-
fragments <- normalizePath(path = fragments, mustWork = TRUE)
58-
max_lines <- SetIfNull(x = max_lines, y = 0)
59-
verbose = as.logical(x = verbose)
60-
if (!is.null(x = cells)) {
61-
cells <- unique(x = cells)
66+
for (i in seq_along(along.with = fragments)) {
67+
if (isRemote(x = i)) {
68+
stop("Remote fragment files not supported")
69+
}
70+
fragments[[i]] <- normalizePath(path = fragments[[i]], mustWork = TRUE)
71+
max_lines <- SetIfNull(x = max_lines, y = 0)
72+
verbose = as.logical(x = verbose)
73+
if (!is.null(x = cells)) {
74+
cells <- unique(x = cells)
75+
}
76+
counts <- groupCommand(
77+
fragments = fragments[[i]],
78+
some_whitelist_cells = cells,
79+
max_lines = max_lines,
80+
verbose = verbose
81+
)
82+
rownames(x = counts) <- counts$CB
83+
counts$CB <- NULL
84+
if (i == 1) {
85+
# first file
86+
allcounts <- counts
87+
} else {
88+
# merge
89+
common <- intersect(
90+
x = rownames(x = allcounts), y = rownames(x = counts)
91+
)
92+
allcounts[common, ] <- allcounts[common, ] + counts[common, ]
93+
missing_cells <- setdiff(x = rownames(x = counts), y = common)
94+
allcounts <- rbind(allcounts, counts[missing_cells, ])
95+
}
6296
}
63-
counts <- groupCommand(
64-
fragments = fragments,
65-
some_whitelist_cells = cells,
66-
max_lines = max_lines,
67-
verbose = verbose
68-
)
69-
return(counts)
97+
# reformat for backwards compatibility
98+
allcounts$CB <- rownames(x = allcounts)
99+
rownames(x = allcounts) <- NULL
100+
allcounts <- allcounts[, c(5, 1, 2, 3, 4)]
101+
return(allcounts)
70102
}
71103

72104
#' Filter cells from fragment file

R/generics.R

+14
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,20 @@ IdentifyVariants <- function(object, ...) {
270270
UseMethod(generic = "IdentifyVariants", object = object)
271271
}
272272

273+
#' Region enrichment analysis
274+
#'
275+
#' Count fragments within a set of regions for different groups of
276+
#' cells.
277+
#'
278+
#' @param object A Seurat or ChromatinAssay object
279+
#' @param ... Arguments passed to other methods
280+
#' @return Returns a \code{\link[SeuratObject]{Seurat}} object
281+
#' @rdname RegionMatrix
282+
#' @export RegionMatrix
283+
RegionMatrix <- function(object, ...) {
284+
UseMethod(generic = "RegionMatrix", object = object)
285+
}
286+
273287
#' Compute base composition information for genomic ranges
274288
#'
275289
#' Compute the GC content, region lengths, and dinucleotide base frequencies

0 commit comments

Comments
 (0)