diff --git a/DESCRIPTION b/DESCRIPTION index 6a7f091..dc71648 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: raer Type: Package Title: RNA editing tools in R -Version: 1.1.3 +Version: 1.1.2 Authors@R: c( person("Kent", "Riemondy", , "kent.riemondy@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0750-1273")), @@ -22,7 +22,6 @@ License: MIT + file LICENSE Imports: stats, methods, - data.table, GenomicRanges, IRanges, Rsamtools, @@ -38,7 +37,6 @@ Imports: BiocParallel, rtracklayer, Matrix, - R.utils, cli Suggests: testthat (>= 3.0.0), @@ -65,7 +63,7 @@ SystemRequirements: VignetteBuilder: knitr Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 URL: https://rnabioco.github.io/raer, https://github.com/rnabioco/raer BugReports: https://github.com/rnabioco/raer/issues biocViews: diff --git a/NAMESPACE b/NAMESPACE index 4b21419..75b711e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -57,7 +57,6 @@ importFrom(IRanges,extractList) importFrom(IRanges,subsetByOverlaps) importFrom(Matrix,colSums) importFrom(Matrix,sparseMatrix) -importFrom(R.utils,gzip) importFrom(Rsamtools,BamFile) importFrom(Rsamtools,BamFileList) importFrom(Rsamtools,FaFile) @@ -71,7 +70,6 @@ importFrom(Rsamtools,seqinfo) importFrom(S4Vectors,aggregate) importFrom(S4Vectors,unstrsplit) importFrom(SingleCellExperiment,SingleCellExperiment) -importFrom(data.table,fread) importFrom(methods,"slot<-") importFrom(methods,as) importFrom(methods,is) diff --git a/R/sc-pileup.R b/R/sc-pileup.R index 91404c5..d98fb77 100644 --- a/R/sc-pileup.R +++ b/R/sc-pileup.R @@ -336,7 +336,8 @@ get_sc_pileup <- function(bamfn, index, id, sites, barcodes, #' intervals, whereas `index`` will only add row indices to the rownames. #' @returns a `SingleCellExperiment` object populated with `nRef` and `nAlt` #' assays. -#' +#' +#' @importFrom utils read.table #' @examples #' library(Rsamtools) #' library(GenomicRanges) @@ -359,10 +360,8 @@ get_sc_pileup <- function(bamfn, index, id, sites, barcodes, #' #' unlink(bai) #' -#' @importFrom data.table fread #' @importFrom Matrix sparseMatrix #' @importFrom SingleCellExperiment SingleCellExperiment -#' @importFrom R.utils gzip #' @export read_sparray <- function(mtx_fn, sites_fn, bc_fn, site_format = c("coordinate", "index")) { @@ -370,7 +369,7 @@ read_sparray <- function(mtx_fn, sites_fn, bc_fn, return(SingleCellExperiment::SingleCellExperiment()) } - rnames <- data.table::fread(sites_fn, + rnames <- read.table(sites_fn, sep = "\t", col.names = c( "index", "seqnames", "start", @@ -380,7 +379,7 @@ read_sparray <- function(mtx_fn, sites_fn, bc_fn, "integer", "character", "integer", "integer", "character", "character" ), - data.table = FALSE + row.names = NULL ) site_format <- match.arg(site_format) @@ -404,7 +403,7 @@ read_sparray <- function(mtx_fn, sites_fn, bc_fn, n_sp_cols <- 2 + length(sp_mtx_names) if (file.size(mtx_fn) > 0) { - dt <- data.table::fread(mtx_fn, + dt <- read.table(mtx_fn, sep = " ", colClasses = "integer", skip = n_skip, @@ -443,6 +442,7 @@ read_sparray <- function(mtx_fn, sites_fn, bc_fn, res } +#' @importFrom utils write.table write_sparray <- function(sce, mtx_fn, sites_fn, bc_fn) { if (!all(c("nRef", "nAlt") %in% assayNames(sce))) { cli::cli_abort("missing required asssays nRef or nAlt") @@ -474,7 +474,6 @@ write_sparray <- function(sce, mtx_fn, sites_fn, bc_fn) { mtx_fn ) - mtx <- matrix(0L, nrow = dim(nref_trpl)[1], ncol = 4L) mtx <- cbind(nref_trpl, nalt = nalt_trpl$x) write.table(mtx, diff --git a/man/find_de_sites.Rd b/man/find_de_sites.Rd index 098346c..17d111a 100644 --- a/man/find_de_sites.Rd +++ b/man/find_de_sites.Rd @@ -66,9 +66,10 @@ rse$condition <- substr(rse$sample, 1, 2) rse <- calc_edit_frequency(rse) dse <- make_de_object(rse) -res <- find_de_sites(dse, - condition_control = "WT", - condition_treatment = "KO") +res <- find_de_sites(dse, + condition_control = "WT", + condition_treatment = "KO" +) res$sig_results[1:3, ] } diff --git a/man/raer.Rd b/man/raer.Rd index ff36a1f..f8afa4b 100644 --- a/man/raer.Rd +++ b/man/raer.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/raer.R \docType{package} \name{raer} -\alias{raer} \alias{raer-package} +\alias{raer} \title{raer: RNA editing tools in R} \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} diff --git a/tests/testthat/test_aei.R b/tests/testthat/test_aei.R index 1fb8b25..0721eca 100644 --- a/tests/testthat/test_aei.R +++ b/tests/testthat/test_aei.R @@ -1,4 +1,4 @@ -pkgs <- c("Rsamtools", "data.table", "Biostrings") +pkgs <- c("Rsamtools", "Biostrings") msg <- lapply(pkgs, function(x) { suppressPackageStartupMessages(library(x, character.only = TRUE)) }) @@ -29,13 +29,17 @@ test_that("calc_aei basic options work", { expect_true(ag_aei["wt"] > ag_aei["ko"]) x <- aei$AEI_per_chrom - setDT(x) - pc_aei <- x[, 100 * (sum(alt) / sum(alt + ref)), by = .(allele, bam_file)] - pc_aei <- dcast(pc_aei, bam_file ~ allele, value.var = "V1") - pc_aei <- as.data.frame(pc_aei) - rownames(pc_aei) <- pc_aei$bam_file - pc_aei$bam_file <- NULL - expect_true(identical(pc_aei, as.data.frame(aei$AEI))) + xx <- lapply(split(x, ~ allele + bam_file), function(x) { + xx <- 100 * (sum(x$alt) / sum(x$alt + x$ref)) + data.frame(allele = unique(x$allele), + bam_file = unique(x$bam_file), + total = xx) + }) |> do.call(rbind, args = _) + xx <- reshape(xx, idvar = c("bam_file"), v.names = "total", timevar = "allele", direction = "wide") + rownames(xx) <- xx$bam_file + xx$bam_file <- NULL + colnames(xx) <- sub("total.", "", colnames(xx)) + expect_true(identical(data.frame(xx), as.data.frame(aei$AEI))) aei <- calc_AEI(unname(bams), fafn, mock_alu_ranges) expect_true(all(rownames(aei$AEI) == unname(bams)))