Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
timoast committed Mar 6, 2022
2 parents 63d61be + 8a17721 commit 458e647
Show file tree
Hide file tree
Showing 30 changed files with 1,928 additions and 628 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmd-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env:
run_covr: 'false'
run_pkgdown: 'false'
has_RUnit: 'false'
cache-version: 'cache-v1'
cache-version: 'cache-v3'
run_docker: 'false'

jobs:
Expand All @@ -54,7 +54,7 @@ jobs:
fail-fast: false
matrix:
config:
- { 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" }
- { 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" }

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Signac
Title: Analysis of Single-Cell Chromatin Data
Version: 1.5.0
Date: 2021-12-07
Version: 1.6.0
Date: 2022-03-04
Authors@R: c(
person(given = 'Tim', family = 'Stuart', email = '[email protected]', role = c('aut', 'cre'), comment = c(ORCID = '0000-0002-3044-0897')),
person(given = 'Avi', family = 'Srivastava', email = '[email protected]', role = 'aut', comment = c(ORCID = '0000-0001-9798-2079')),
Expand Down Expand Up @@ -30,7 +30,7 @@ Imports:
Matrix,
Rsamtools,
S4Vectors,
Seurat (>= 4.0.0),
Seurat (>= 4.0.6),
SeuratObject (>= 4.0.0),
data.table,
dplyr (>= 1.0.0),
Expand All @@ -54,7 +54,8 @@ Imports:
Rcpp,
ggforce,
qlcMatrix,
grid
grid,
tidyselect
Collate:
'RcppExports.R'
'data.R'
Expand All @@ -65,6 +66,7 @@ Collate:
'fragments.R'
'genomeinfodb-methods.R'
'granges-methods.R'
'heatmaps.R'
'iranges-methods.R'
'links.R'
'mito.R'
Expand All @@ -73,6 +75,7 @@ Collate:
'peaks.R'
'preprocessing.R'
'quantification.R'
'region-enrichment.R'
'utilities.R'
'visualization.R'
'zzz.R'
Expand Down
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ S3method(Links,ChromatinAssay)
S3method(Links,Seurat)
S3method(Motifs,ChromatinAssay)
S3method(Motifs,Seurat)
S3method(RegionMatrix,ChromatinAssay)
S3method(RegionMatrix,Seurat)
S3method(RegionMatrix,default)
S3method(RegionStats,ChromatinAssay)
S3method(RegionStats,Seurat)
S3method(RegionStats,default)
Expand Down Expand Up @@ -145,12 +148,16 @@ export(LinkPlot)
export(Links)
export(LookupGeneCoords)
export(MatchRegionStats)
export(MotifCounts)
export(MotifPlot)
export(Motifs)
export(NucleosomeSignal)
export(PeakPlot)
export(PlotFootprint)
export(ReadMGATK)
export(RegionHeatmap)
export(RegionMatrix)
export(RegionPlot)
export(RegionStats)
export(RunChromVAR)
export(RunSVD)
Expand Down Expand Up @@ -303,6 +310,7 @@ importFrom(Seurat,Project)
importFrom(Seurat,RenameCells)
importFrom(Seurat,RowMergeSparseMatrices)
importFrom(Seurat,SetAssayData)
importFrom(Seurat,SetQuantile)
importFrom(Seurat,VariableFeatures)
importFrom(Seurat,WhichCells)
importFrom(SeuratObject,Cells)
Expand Down Expand Up @@ -340,9 +348,11 @@ importFrom(ggplot2,guide_legend)
importFrom(ggplot2,guides)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_color_gradient2)
importFrom(ggplot2,scale_color_grey)
importFrom(ggplot2,scale_color_identity)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,scale_fill_gradient)
importFrom(ggplot2,scale_fill_grey)
importFrom(ggplot2,scale_fill_manual)
importFrom(ggplot2,scale_fill_viridis_c)
importFrom(ggplot2,scale_x_continuous)
Expand Down Expand Up @@ -393,6 +403,7 @@ importFrom(stats,sd)
importFrom(stringi,stri_split_fixed)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,separate)
importFrom(tidyselect,all_of)
importFrom(tools,file_ext)
importFrom(tools,md5sum)
importFrom(utils,globalVariables)
Expand Down
28 changes: 28 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Signac 1.6.0

New functionality:

* Added `RegionHeatmap()` function
* Added `RegionPlot()` function
* Added `RegionMatrix()` function
* Added `MotifCounts()` function
* Added ability to plot multiple assays simultaneously in `CoveragePlot()` by providing a list of assay names
* Added `assay.scale`, `bigwig.scale`, and `split.assay` parameters to `CoveragePlot()`
* Added new option to provide quantile `ymax` value in `CoveragePlot()`
* Added `bigwig.scale` and `ymax` parameters to `BigwigTrack()`
* Added `peak.slot` parameter to `LinkPeaks()` ([#932](https://github.com/timoast/signac/issues/932))

Bug fixes:

* Fixed behaviour of `min.features` parameter in `CreateChromatinAssay()` to retain cells with `>= min.features` (#[902](https://github.com/timoast/signac/discussions/902))
* Fixed behaviour of `min.cells` parameter in `LinkPeaks()` ([#932](https://github.com/timoast/signac/issues/932))

Other changes:

* Updated documentation for `CoveragePlot()` ([#992](https://github.com/timoast/signac/issues/992))
* Removed `method` parameter from `LinkPeaks()` ([#932](https://github.com/timoast/signac/issues/932))

# Signac 1.5.0

Bug fixes:
Expand All @@ -17,6 +41,10 @@ Other changes:

# Signac 1.4.0

New functionality:

* 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.

Bug fixes:

* Fixed bug in `FindMotifs()` when using only one region as input ([#732](https://github.com/timoast/signac/issues/732))
Expand Down
14 changes: 7 additions & 7 deletions R/footprinting.R
Original file line number Diff line number Diff line change
Expand Up @@ -495,27 +495,27 @@ RunFootprint <- function(
if (verbose) {
message("Computing observed Tn5 insertions per base")
}
dna.sequence <- Biostrings::getSeq(x = genome, Extend(
x = regions,
upstream = 3,
downstream = 3
)
)
if (compute.expected) {
bias <- GetAssayData(object = object, slot = "bias")
if (is.null(x = bias)) {
stop("Insertion bias not computed")
} else {
# add three bases each side here so we can get the hexamer frequencies
# for every position
dna.sequence <- Biostrings::getSeq(x = genome, Extend(
x = regions,
upstream = 3,
downstream = 3
)
)
expected.insertions <- FindExpectedInsertions(
dna.sequence = dna.sequence,
bias = bias,
verbose = verbose
)
}
} else {
expected.insertions <- rep(1, width(x = dna.sequence)[[1]])
expected.insertions <- rep(1, width(x = dna.sequence)[[1]] - 6)
}

# count insertions at each position for each cell
Expand Down
64 changes: 48 additions & 16 deletions R/fragments.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ head.Fragment <- function(x, n = 6L, ...) {
#'
#' Count total fragments per cell barcode present in a fragment file.
#'
#' @param fragments Path to a fragment file
#' @param fragments Path to a fragment file. If a list of fragment files is
#' provided, the total fragments for each cell barcode across all files will be
#' returned
#' @param cells Cells to include. If NULL, include all cells
#' @param max_lines Maximum number of lines to read from the fragment file. If
#' NULL, read all lines in the file.
Expand All @@ -41,7 +43,14 @@ head.Fragment <- function(x, n = 6L, ...) {
#' @rdname CountFragments
#' @export
#' @concept fragments
#' @return Returns a data.frame
#' @return Returns a data.frame with the following columns:
#' \itemize{
#' \item{CB: the cell barcode}
#' \item{frequency_count: total number of fragments sequenced for the cell}
#' \item{mononucleosome: total number of fragments with length between 147 bp and 294 bp}
#' \item{nucleosome_free: total number of fragments with length <147 bp}
#' \item{reads_count: total number of reads sequenced for the cell}
#' }
#' @examples
#' fpath <- system.file("extdata", "fragments.tsv.gz", package="Signac")
#' counts <- CountFragments(fragments = fpath)
Expand All @@ -51,22 +60,45 @@ CountFragments <- function(
max_lines = NULL,
verbose = TRUE
) {
if (isRemote(x = fragments)) {
stop("Remote fragment files not supported")
if (!inherits(x = fragments, what = "list")) {
fragments <- list(fragments)
}
fragments <- normalizePath(path = fragments, mustWork = TRUE)
max_lines <- SetIfNull(x = max_lines, y = 0)
verbose = as.logical(x = verbose)
if (!is.null(x = cells)) {
cells <- unique(x = cells)
for (i in seq_along(along.with = fragments)) {
if (isRemote(x = i)) {
stop("Remote fragment files not supported")
}
fragments[[i]] <- normalizePath(path = fragments[[i]], mustWork = TRUE)
max_lines <- SetIfNull(x = max_lines, y = 0)
verbose = as.logical(x = verbose)
if (!is.null(x = cells)) {
cells <- unique(x = cells)
}
counts <- groupCommand(
fragments = fragments[[i]],
some_whitelist_cells = cells,
max_lines = max_lines,
verbose = verbose
)
rownames(x = counts) <- counts$CB
counts$CB <- NULL
if (i == 1) {
# first file
allcounts <- counts
} else {
# merge
common <- intersect(
x = rownames(x = allcounts), y = rownames(x = counts)
)
allcounts[common, ] <- allcounts[common, ] + counts[common, ]
missing_cells <- setdiff(x = rownames(x = counts), y = common)
allcounts <- rbind(allcounts, counts[missing_cells, ])
}
}
counts <- groupCommand(
fragments = fragments,
some_whitelist_cells = cells,
max_lines = max_lines,
verbose = verbose
)
return(counts)
# reformat for backwards compatibility
allcounts$CB <- rownames(x = allcounts)
rownames(x = allcounts) <- NULL
allcounts <- allcounts[, c(5, 1, 2, 3, 4)]
return(allcounts)
}

#' Filter cells from fragment file
Expand Down
14 changes: 14 additions & 0 deletions R/generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,20 @@ IdentifyVariants <- function(object, ...) {
UseMethod(generic = "IdentifyVariants", object = object)
}

#' Region enrichment analysis
#'
#' Count fragments within a set of regions for different groups of
#' cells.
#'
#' @param object A Seurat or ChromatinAssay object
#' @param ... Arguments passed to other methods
#' @return Returns a \code{\link[SeuratObject]{Seurat}} object
#' @rdname RegionMatrix
#' @export RegionMatrix
RegionMatrix <- function(object, ...) {
UseMethod(generic = "RegionMatrix", object = object)
}

#' Compute base composition information for genomic ranges
#'
#' Compute the GC content, region lengths, and dinucleotide base frequencies
Expand Down
Loading

0 comments on commit 458e647

Please sign in to comment.