Skip to content

Commit

Permalink
Merge branch 'master' into chilampoon-improve-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
stemangiola committed Feb 7, 2024
2 parents 989009a + c0f4e86 commit c54b441
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: tidybulk
Title: Brings transcriptomics to the tidyverse
Version: 1.15.4
Version: 1.15.5
Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
role = c("aut", "cre")),
person("Maria", "Doyle", email = "[email protected]",
Expand Down Expand Up @@ -94,7 +94,7 @@ Biarch: true
biocViews: AssayDomain, Infrastructure, RNASeq, DifferentialExpression, GeneExpression, Normalization, Clustering, QualityControl, Sequencing, Transcription, Transcriptomics
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
LazyDataCompression: xz
URL: https://github.com/stemangiola/tidybulk
BugReports: https://github.com/stemangiola/tidybulk/issues
10 changes: 5 additions & 5 deletions R/glmmSeq.R
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ glmmSeq = function (modelFormula, countdata, metadata, id = NULL, dispersion = N
resultList <- lapply(fullList, function(geneList) {
glmerCore(geneList, fullFormula, reduced,
subsetMetadata, control, offset, modelData,
designMatrix, hyp.matrix,, max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
designMatrix, hyp.matrix, max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
})
}
else if (Sys.info()["sysname"] == "Windows" & cores > 1) {
Expand Down Expand Up @@ -620,7 +620,7 @@ glmmSeq = function (modelFormula, countdata, metadata, id = NULL, dispersion = N
else {

if(avoid_forking){
library(parallel)
#library(parallel)
cl = parallel::makeCluster(cores, type = "PSOCK")
#parallel::clusterEvalQ(cl,c(library(dplyr),library(glmmSeq)))
#clusterExport(cl, list("varname1", "varname2"),envir=environment())
Expand All @@ -630,7 +630,7 @@ glmmSeq = function (modelFormula, countdata, metadata, id = NULL, dispersion = N
function(geneList) {
glmerCore(geneList, fullFormula, reduced,
subsetMetadata, control, offset, modelData,
designMatrix, hyp.matrix,, max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
designMatrix, hyp.matrix, max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
}
)
}
Expand All @@ -648,7 +648,7 @@ glmmSeq = function (modelFormula, countdata, metadata, id = NULL, dispersion = N
resultList <- pbmcapply::pbmclapply(fullList, function(geneList) {
glmerCore(geneList, fullFormula, reduced,
subsetMetadata, control, offset, modelData,
designMatrix, hyp.matrix, , max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
designMatrix, hyp.matrix, max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
}, mc.cores = cores)
if ("value" %in% names(resultList)) resultList <- resultList$value

Expand All @@ -657,7 +657,7 @@ glmmSeq = function (modelFormula, countdata, metadata, id = NULL, dispersion = N
resultList <- mclapply(fullList, function(geneList) {
glmerCore(geneList, fullFormula, reduced,
subsetMetadata, control, offset, modelData,
designMatrix, hyp.matrix,, max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
designMatrix, hyp.matrix, max_rows_for_matrix_multiplication = max_rows_for_matrix_multiplication, ...)
}, mc.cores = cores)

}
Expand Down
48 changes: 23 additions & 25 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setOldClass("tidybulk")
#'
#' @importFrom rlang enquo
#' @importFrom rlang quo_is_missing
#' @importFrom magrittr "%>%"
#'
#' @import readr
#' @import SummarizedExperiment
#' @import methods
Expand Down Expand Up @@ -292,7 +292,7 @@ setMethod("as_SummarizedExperiment", "tidybulk", .as_SummarizedExperiment)
#' @description tidybulk_SAM_BAM() creates a `tt` object from A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment))
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name tidybulk_SAM_BAM
#'
Expand Down Expand Up @@ -342,7 +342,7 @@ setMethod("tidybulk_SAM_BAM", c(file_names = "character", genome = "character"),
#' @description scale_abundance() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and Scales transcript abundance compansating for sequencing depth (e.g., with TMM algorithm, Robinson and Oshlack doi.org/10.1186/gb-2010-11-3-r25).
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#' @importFrom stats median
#'
#' @name scale_abundance
Expand Down Expand Up @@ -566,7 +566,7 @@ setMethod("scale_abundance", "tidybulk", .scale_abundance)
#' @description quantile_normalise_abundance() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and Scales transcript abundance compansating for sequencing depth (e.g., with TMM algorithm, Robinson and Oshlack doi.org/10.1186/gb-2010-11-3-r25).
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#' @importFrom stats median
#' @importFrom dplyr join_by
#' @importFrom limma normalizeQuantiles
Expand Down Expand Up @@ -750,7 +750,7 @@ setMethod("quantile_normalise_abundance", "tidybulk", .quantile_normalise_abunda
#' @description cluster_elements() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and identify clusters in the data.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name cluster_elements
#'
Expand Down Expand Up @@ -967,7 +967,7 @@ setMethod("cluster_elements", "tidybulk", .cluster_elements)
#' @description reduce_dimensions() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and calculates the reduced dimensional space of the transcript abundance.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name reduce_dimensions
#'
Expand Down Expand Up @@ -1256,7 +1256,7 @@ setMethod("reduce_dimensions", "tidybulk", .reduce_dimensions)
#' dimensional space of the transcript abundance.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name rotate_dimensions
#'
Expand Down Expand Up @@ -1437,7 +1437,7 @@ setMethod("rotate_dimensions", "tidybulk", .rotate_dimensions)
#' @description remove_redundancy() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) for correlation method or | <DIMENSION 1> | <DIMENSION 2> | <...> | for reduced_dimensions method, and returns a consistent object (to the input) with dropped elements (e.g., samples).
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name remove_redundancy
#'
Expand Down Expand Up @@ -1659,7 +1659,7 @@ setMethod("remove_redundancy", "tidybulk", .remove_redundancy)
#' This method uses scaled counts if present.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name adjust_abundance
#'
Expand Down Expand Up @@ -1924,7 +1924,7 @@ setMethod("adjust_abundance", "tidybulk", .adjust_abundance)
#' @description aggregate_duplicates() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with aggregated transcripts that were duplicated.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name aggregate_duplicates
#'
Expand Down Expand Up @@ -2074,7 +2074,7 @@ setMethod("aggregate_duplicates", "tidybulk", .aggregate_duplicates)
#' @description deconvolve_cellularity() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with the estimated cell type abundance for each sample
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name deconvolve_cellularity
#'
Expand Down Expand Up @@ -2410,7 +2410,7 @@ setMethod("describe_transcript", "tidybulk", .describe_transcript)
#' @description ensembl_to_symbol() takes as input a `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with the additional transcript symbol column
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name ensembl_to_symbol
#'
Expand Down Expand Up @@ -2528,7 +2528,7 @@ setMethod("ensembl_to_symbol", "tidybulk", .ensembl_to_symbol)
#' @description test_differential_abundance() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with additional columns for the statistics from the hypothesis test.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name test_differential_abundance
#'
Expand Down Expand Up @@ -2948,7 +2948,7 @@ setMethod("test_differential_abundance",
#' @description keep_variable() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with additional columns for the statistics from the hypothesis test.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name keep_variable
#'
Expand Down Expand Up @@ -3075,7 +3075,7 @@ setMethod("keep_variable", "tidybulk", .keep_variable)
#' @description identify_abundant() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with additional columns for the statistics from the hypothesis test.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#' @importFrom dplyr filter
#' @importFrom tidyr drop_na
#' @importFrom edgeR filterByExpr
Expand Down Expand Up @@ -3286,7 +3286,7 @@ setMethod("identify_abundant", "tidybulk", .identify_abundant)
#' @description keep_abundant() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with additional columns for the statistics from the hypothesis test.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#' @importFrom dplyr filter
#'
#' @name keep_abundant
Expand Down Expand Up @@ -3422,7 +3422,7 @@ setMethod("keep_abundant", "tidybulk", .keep_abundant)
#' library(tidySummarizedExperiment)) and returns a `tbl` of gene set information
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name test_gene_enrichment
#'
Expand Down Expand Up @@ -3665,7 +3665,6 @@ setMethod("test_gene_enrichment",
#'
#' @importFrom rlang enquo
#' @importFrom rlang quo_is_missing
#' @importFrom magrittr "%>%"
#' @importFrom msigdbr msigdbr_species
#'
#' @name test_gene_overrepresentation
Expand Down Expand Up @@ -3818,7 +3817,6 @@ setMethod("test_gene_overrepresentation",
#'
#' @importFrom rlang enquo
#' @importFrom rlang quo_is_missing
#' @importFrom magrittr "%>%"
#' @importFrom msigdbr msigdbr_species
#'
#' @name test_gene_rank
Expand Down Expand Up @@ -4021,7 +4019,7 @@ setMethod("test_gene_rank",
#'
#' @description pivot_sample() takes as input a `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a `tbl` with only sample-related columns
#'
#' @importFrom magrittr "%>%"
#'
#'
#' @name pivot_sample
#'
Expand Down Expand Up @@ -4110,7 +4108,7 @@ setMethod("pivot_sample",
#'
#' @description pivot_transcript() takes as input a `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a `tbl` with only transcript-related columns
#'
#' @importFrom magrittr "%>%"
#'
#'
#' @name pivot_transcript
#'
Expand Down Expand Up @@ -4201,7 +4199,7 @@ setMethod("pivot_transcript",
#' @description fill_missing_abundance() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with new observations
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name fill_missing_abundance
#'
Expand Down Expand Up @@ -4308,7 +4306,7 @@ setMethod("fill_missing_abundance", "tidybulk", .fill_missing_abundance)
#' @description impute_missing_abundance() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with additional sample-transcript pairs with imputed transcript abundance.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name impute_missing_abundance
#'
Expand Down Expand Up @@ -4605,7 +4603,7 @@ setMethod("test_differential_cellularity",
#' @description test_stratification_cellularity() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and returns a consistent object (to the input) with additional columns for the statistics from the hypothesis test.
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#' @importFrom stringr str_detect
#'
#' @name test_stratification_cellularity
Expand Down Expand Up @@ -4749,7 +4747,7 @@ setMethod("test_stratification_cellularity",
#' @description get_bibliography() takes as input a `tidybulk`
#'
#' @importFrom rlang enquo
#' @importFrom magrittr "%>%"
#'
#'
#' @name get_bibliography
#'
Expand Down
7 changes: 4 additions & 3 deletions tests/testthat/test-bulk_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ test_that("differential trancript abundance - random effects",{

filter(b %in% c("ABCB4" , "ABCB9" , "ACAP1", "ACHE", "ACP5" , "ADAM28"))

set.seed(42)
my_input |>
test_differential_abundance(
~ condition + (1 + condition | time),
Expand All @@ -849,7 +850,7 @@ test_that("differential trancript abundance - random effects",{
pull(P_condition_adjusted) |>
head(4) |>
expect_equal(
c(0.03643414, 0.02938584, 0.02938584, 0.03643414),
c(0.02658234, 0.02658234, 0.02658234, 0.04139992),
tolerance=1e-3
)

Expand All @@ -861,7 +862,7 @@ test_that("differential trancript abundance - random effects",{
by = join_by(b, entrez, .abundant)
)


set.seed(42)
my_input |>
test_differential_abundance(
~ condition + (1 + condition | time),
Expand All @@ -876,7 +877,7 @@ test_that("differential trancript abundance - random effects",{
pull(P_condition_adjusted) |>
head(4) |>
expect_equal(
c(0.1081176, 0.1303558, 0.1303558, 0.1693276),
c(0.08686834, 0.14384610, 0.14384610, 0.19750844),
tolerance=1e-2
)

Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-bulk_methods_SummarizedExperiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ test_that("Voom with treat method",{

test_that("differential trancript abundance - random effects SE",{

set.seed(42)
res =
se_mini[1:10,] |>
identify_abundant(factor_of_interest = condition) |>
Expand All @@ -493,7 +494,7 @@ test_that("differential trancript abundance - random effects SE",{
rowData(res)[,"P_condition_adjusted"] |>
head(4) |>
expect_equal(
c(0.03394914, 0.03394914, 0.03394914, NA),
c(0.1578695, 0.1221392, 0.1221392, 0.2262688),
tolerance=1e-2
)

Expand All @@ -517,7 +518,7 @@ test_that("differential trancript abundance - random effects SE",{
rowData(res)[,"P_condition_adjusted"] |>
head(4) |>
expect_equal(
c(0.1153254, 0.1668555, 0.1668555 , NA),
c(0.2633982, 0.2633982, 0.2633982, 0.5028348),
tolerance=1e-2
)

Expand Down

0 comments on commit c54b441

Please sign in to comment.