Skip to content

Commit 189fc1c

Browse files
authored
Merge pull request #54 from fmicompbio/bioc
Preparation for Bioc submission
2 parents 03b2407 + cc199f8 commit 189fc1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2189
-1302
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
config:
21-
- { os: macOS-latest, bioc: 'release', curlConfigPath: '/usr/bin/'}
22-
- { os: windows-latest, bioc: 'release'}
23-
- { os: ubuntu-latest, image: "bioconductor/bioconductor_docker:RELEASE_3_20", cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
21+
- { os: macOS-latest, bioc: 'devel', curlConfigPath: '/usr/bin/'}
22+
- { os: windows-latest, bioc: 'devel'}
23+
- { os: ubuntu-latest, image: "bioconductor/bioconductor_docker:devel", cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
2424

2525
env:
2626
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true

DESCRIPTION

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: mutscan
22
Title: Preprocessing and Analysis of Deep Mutational Scanning Data
3-
Version: 0.3.4
3+
Version: 0.99.0
44
Authors@R:
55
c(person(given = "Charlotte",
66
family = "Soneson",
@@ -20,7 +20,7 @@ Description: Provides functionality for processing and statistical analysis
2020
files to publication-ready visualizations. A broad range of library
2121
designs can be processed with a single, unified interface.
2222
Depends:
23-
R (>= 3.5)
23+
R (>= 4.5.0)
2424
Imports:
2525
BiocGenerics,
2626
S4Vectors,
@@ -45,18 +45,18 @@ Imports:
4545
DT,
4646
ggrepel,
4747
IRanges,
48-
zlibbioc,
4948
utils,
5049
DelayedArray,
51-
lifecycle
50+
tools
5251
Suggests:
5352
testthat (>= 3.0.0),
5453
BiocStyle,
5554
knitr,
5655
Biostrings,
5756
pwalign,
5857
plotly,
59-
scattermore
58+
scattermore,
59+
BiocManager
6060
SystemRequirements: GNU make
6161
biocViews: GeneticVariability, GenomicVariation, Preprocessing
6262
License: MIT + file LICENSE
@@ -66,3 +66,5 @@ VignetteBuilder: knitr
6666
LinkingTo:
6767
Rcpp
6868
Config/testthat/edition: 3
69+
URL: https://github.com/fmicompbio/mutscan
70+
BugReports: https://github.com/fmicompbio/mutscan/issues

NAMESPACE

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ export(plotTotals)
1818
export(plotVolcano)
1919
export(relabelMutPositions)
2020
export(summarizeExperiment)
21-
import(zlibbioc)
22-
importFrom(BiocGenerics,paste)
21+
importFrom(BiocGenerics,"rownames<-")
2322
importFrom(BiocGenerics,rownames)
2423
importFrom(DT,datatable)
2524
importFrom(DelayedArray,rowsum)
2625
importFrom(GGally,eval_data_col)
2726
importFrom(GGally,ggpairs)
28-
importFrom(GGally,wrap)
2927
importFrom(IRanges,IntegerList)
3028
importFrom(Matrix,colSums)
3129
importFrom(Matrix,rowMeans)
@@ -34,14 +32,14 @@ importFrom(Rcpp,sourceCpp)
3432
importFrom(S4Vectors,DataFrame)
3533
importFrom(S4Vectors,metadata)
3634
importFrom(S4Vectors,unstrsplit)
35+
importFrom(SummarizedExperiment,"rowData<-")
3736
importFrom(SummarizedExperiment,SummarizedExperiment)
3837
importFrom(SummarizedExperiment,assay)
3938
importFrom(SummarizedExperiment,assayNames)
4039
importFrom(SummarizedExperiment,assays)
4140
importFrom(SummarizedExperiment,colData)
4241
importFrom(SummarizedExperiment,rowData)
4342
importFrom(csaw,normOffsets)
44-
importFrom(dplyr,"%>%")
4543
importFrom(dplyr,across)
4644
importFrom(dplyr,arrange)
4745
importFrom(dplyr,bind_rows)
@@ -72,6 +70,7 @@ importFrom(ggplot2,after_stat)
7270
importFrom(ggplot2,annotate)
7371
importFrom(ggplot2,coord_cartesian)
7472
importFrom(ggplot2,element_blank)
73+
importFrom(ggplot2,element_rect)
7574
importFrom(ggplot2,element_text)
7675
importFrom(ggplot2,facet_wrap)
7776
importFrom(ggplot2,geom_abline)
@@ -99,9 +98,6 @@ importFrom(ggrepel,geom_text_repel)
9998
importFrom(grDevices,colorRamp)
10099
importFrom(grDevices,hcl.colors)
101100
importFrom(grDevices,rgb)
102-
importFrom(lifecycle,deprecate_warn)
103-
importFrom(lifecycle,deprecated)
104-
importFrom(lifecycle,is_present)
105101
importFrom(limma,contrasts.fit)
106102
importFrom(limma,eBayes)
107103
importFrom(limma,lmFit)
@@ -118,9 +114,10 @@ importFrom(tibble,rownames_to_column)
118114
importFrom(tidyr,gather)
119115
importFrom(tidyr,separate)
120116
importFrom(tidyr,separate_rows)
121-
importFrom(tidyr,unite)
122117
importFrom(tidyselect,matches)
118+
importFrom(tools,file_ext)
123119
importFrom(utils,globalVariables)
120+
importFrom(utils,packageVersion)
124121
importFrom(utils,relist)
125122
importFrom(xfun,Rscript_call)
126123
useDynLib(mutscan, .registration = TRUE)

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# mutscan 0.99.0
2+
3+
* Prepare for Bioconductor submission
4+
* Remove deprecated arguments variableCollapseMaxDist, variableCollapseMinReads and variableCollapseMinRatio from digestFastqs (deprecated in mutscan 0.3.0)
5+
16
# mutscan 0.3.4
27

38
* Allow use of scattermore/scattermost in plotPairs

R/RcppExports.R

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ calcNearestStringDist <- function(x, metric = "hamming", nThreads = 1L) {
2424
.Call(`_mutscan_calcNearestStringDist`, x, metric, nThreads)
2525
}
2626

27+
complement <- function(n) {
28+
.Call(`_mutscan_complement`, n)
29+
}
30+
2731
compareCodonPositions <- function(a, b, mutNameDelimiter) {
2832
.Call(`_mutscan_compareCodonPositions`, a, b, mutNameDelimiter)
2933
}
@@ -40,6 +44,10 @@ test_makeAAHGVS <- function(mutationsSorted, mutNameDelimiter, wtSeq) {
4044
.Call(`_mutscan_test_makeAAHGVS`, mutationsSorted, mutNameDelimiter, wtSeq)
4145
}
4246

47+
test_compareToWildtype <- function(varSeq, wtSeq, varIntQual, forbiddenCodons_vect, mutatedPhredMin = 0.0, nbrMutatedCodonsMax = -1L, codonPrefix = "c", nbrMutatedBasesMax = -1L, mutNameDelimiter = ".", collapseToWT = FALSE) {
48+
.Call(`_mutscan_test_compareToWildtype`, varSeq, wtSeq, varIntQual, forbiddenCodons_vect, mutatedPhredMin, nbrMutatedCodonsMax, codonPrefix, nbrMutatedBasesMax, mutNameDelimiter, collapseToWT)
49+
}
50+
4351
test_decomposeRead <- function(sseq, squal, elements, elementLengths, primerSeqs, umiSeq, varSeq, varQual, varLengths, constSeq, constQual, nNoPrimer, nReadWrongLength) {
4452
.Call(`_mutscan_test_decomposeRead`, sseq, squal, elements, elementLengths, primerSeqs, umiSeq, varSeq, varQual, varLengths, constSeq, constQual, nNoPrimer, nReadWrongLength)
4553
}
@@ -57,45 +65,45 @@ findClosestRefSeqEarlyStop <- function(varSeq, wtSeq, upperBoundMismatch, sim) {
5765
}
5866

5967
#' Create a conversion table for collapsing similar sequences
60-
#' @param seqs Character vector with nucleotide sequences (or pairs of
61-
#' sequences concatenated with "_") to be collapsed. The sequences must
68+
#' @param seqs Character vector with nucleotide sequences (or pairs of
69+
#' sequences concatenated with "_") to be collapsed. The sequences must
6270
#' all be of the same length.
6371
#' @param scores Numeric vector of "scores" for the sequences. Typically
64-
#' the total read/UMI count. A higher score will be preferred when
65-
#' deciding which sequence to use as the representative for a group of
72+
#' the total read/UMI count. A higher score will be preferred when
73+
#' deciding which sequence to use as the representative for a group of
6674
#' collapsed sequences.
67-
#' @param collapseMaxDist Numeric scalar defining the tolerance for collapsing
68-
#' similar sequences. If the value is in [0, 1), it defines the maximal
75+
#' @param collapseMaxDist Numeric scalar defining the tolerance for collapsing
76+
#' similar sequences. If the value is in [0, 1), it defines the maximal
6977
#' Hamming distance in terms of a fraction of sequence length:
7078
#' (\code{round(collapseMaxDist * nchar(sequence))}).
7179
#' A value greater or equal to 1 is rounded and directly used as the maximum
7280
#' allowed Hamming distance. Note that sequences can only be
73-
#' collapsed if they are all of the same length.
74-
#' @param collapseMinScore Numeric scalar, indicating the minimum score
75-
#' required for a sequence to be considered as a representative for a
76-
#' group of similar sequences (i.e., to allow other sequences to be
77-
#' collapsed into it).
81+
#' collapsed if they are all of the same length. The default value is 0.
82+
#' @param collapseMinScore Numeric scalar, indicating the minimum score
83+
#' required for a sequence to be considered as a representative for a
84+
#' group of similar sequences (i.e., to allow other sequences to be
85+
#' collapsed into it). The default value is 0.
7886
#' @param collapseMinRatio Numeric scalar. During collapsing of
79-
#' similar sequences, a low-frequency sequence will be collapsed
80-
#' with a higher-frequency sequence only if the ratio between the
81-
#' high-frequency and the low-frequency scores is at least this
87+
#' similar sequences, a low-frequency sequence will be collapsed
88+
#' with a higher-frequency sequence only if the ratio between the
89+
#' high-frequency and the low-frequency scores is at least this
8290
#' high. A value of 0 indicates that no such check is performed.
8391
#' @param verbose Logical scalar, whether to print progress messages.
84-
#'
85-
#' @return A data.frame with two columns, containing the input sequences
92+
#'
93+
#' @return A data.frame with two columns, containing the input sequences
8694
#' and the representatives for the groups resulting from grouping similar
8795
#' sequences, respectively.
88-
#'
96+
#'
8997
#' @examples
9098
#' seqs <- c("AACGTAGCA", "ACCGTAGCA", "AACGGAGCA", "ATCGGAGCA", "TGAGGCATA")
9199
#' scores <- c(5, 1, 3, 1, 8)
92-
#' groupSimilarSequences(seqs = seqs, scores = scores,
93-
#' collapseMaxDist = 1, collapseMinScore = 0,
100+
#' groupSimilarSequences(seqs = seqs, scores = scores,
101+
#' collapseMaxDist = 1, collapseMinScore = 0,
94102
#' collapseMinRatio = 0, verbose = FALSE)
95-
#'
103+
#'
96104
#' @export
97105
#' @author Michael Stadler, Charlotte Soneson
98-
groupSimilarSequences <- function(seqs, scores, collapseMaxDist, collapseMinScore, collapseMinRatio, verbose) {
106+
groupSimilarSequences <- function(seqs, scores, collapseMaxDist = 0.0, collapseMinScore = 0.0, collapseMinRatio = 0.0, verbose = FALSE) {
99107
.Call(`_mutscan_groupSimilarSequences`, seqs, scores, collapseMaxDist, collapseMinScore, collapseMinRatio, verbose)
100108
}
101109

R/calculateFitnessScore.R

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,23 @@ calculateFitnessScore <- function(se, pairingCol, ODCols, comparison, WTrows,
5959

6060
## pairingCol is in colData(se)
6161
.assertScalar(x = pairingCol, type = "character",
62-
validValues = colnames(SummarizedExperiment::colData(se)))
62+
validValues = colnames(colData(se)))
6363

6464
## ODCols are all in colData(se) and contain numeric values
6565
.assertVector(x = ODCols, type = "character", rngLen = c(1, Inf),
66-
validValues = colnames(SummarizedExperiment::colData(se)))
66+
validValues = colnames(colData(se)))
6767
for (odc in ODCols) {
68-
.assertVector(x = SummarizedExperiment::colData(se)[[odc]],
68+
.assertVector(x = colData(se)[[odc]],
6969
type = "numeric")
7070
}
7171

7272
## comparison is length(3)-character with column and values in colData(se)
7373
.assertVector(x = comparison, type = "character", len = 3)
7474
.assertScalar(x = comparison[1], type = "character",
75-
validValues = colnames(SummarizedExperiment::colData(se)))
76-
.assertVector(x = comparison[2:3], type = "character",
77-
validValues = SummarizedExperiment::colData(se)[[comparison[1]]])
75+
validValues = colnames(colData(se)))
76+
.assertVector(
77+
x = comparison[2:3], type = "character",
78+
validValues = colData(se)[[comparison[1]]])
7879

7980
## there is exactly one observation per pairing and condition
8081
if (any(table(colData(se)[colData(se)[, comparison[1]] %in%
@@ -100,25 +101,29 @@ calculateFitnessScore <- function(se, pairingCol, ODCols, comparison, WTrows,
100101
colData(se_denominator)[, pairingCol])
101102
se_numerator <- se_numerator[, match(shared_repl,
102103
colData(se_numerator)[, pairingCol])]
103-
se_denominator <- se_denominator[, match(shared_repl,
104-
colData(se_denominator)[, pairingCol])]
104+
se_denominator <-
105+
se_denominator[, match(shared_repl,
106+
colData(se_denominator)[, pairingCol])]
105107

106108
## ------------------------------------------------------------------------
107109
## calculate normalized counts (n_i)
108110
## ------------------------------------------------------------------------
109111
norm_counts_numerator <- sweep(
110112
as.matrix(assay(se_numerator, selAssay)), MARGIN = 2,
111-
STATS = apply(colData(se_numerator)[, ODCols, drop = FALSE], MARGIN = 1, prod) /
112-
Matrix::colSums(assay(se_numerator, selAssay)),
113+
STATS = apply(colData(se_numerator)[, ODCols, drop = FALSE],
114+
MARGIN = 1, prod) /
115+
colSums(assay(se_numerator, selAssay)),
113116
FUN = "*")
114117
norm_counts_denominator <- sweep(
115118
as.matrix(assay(se_denominator, selAssay)), MARGIN = 2,
116-
STATS = apply(colData(se_denominator)[, ODCols, drop = FALSE], MARGIN = 1, prod) /
117-
Matrix::colSums(assay(se_denominator, selAssay)),
119+
STATS = apply(colData(se_denominator)[, ODCols, drop = FALSE],
120+
MARGIN = 1, prod) /
121+
colSums(assay(se_denominator, selAssay)),
118122
FUN = "*")
119123
n <- log2(norm_counts_numerator/norm_counts_denominator)
120124
n[!is.finite(n)] <- NA
121-
colnames(n) <- paste0(comparison[2], "_vs_", comparison[3], "_repl", shared_repl)
125+
colnames(n) <- paste0(comparison[2], "_vs_", comparison[3],
126+
"_repl", shared_repl)
122127

123128

124129
## ------------------------------------------------------------------------
@@ -131,4 +136,4 @@ calculateFitnessScore <- function(se, pairingCol, ODCols, comparison, WTrows,
131136
}
132137
fitness <- sweep(n, MARGIN = 2, STATS = nWT, FUN = "/")
133138
return(fitness)
134-
}
139+
}

0 commit comments

Comments
 (0)