Skip to content

Commit

Permalink
drop genomic-unstranded option
Browse files Browse the repository at this point in the history
  • Loading branch information
kriemo committed Aug 28, 2023
1 parent 5442866 commit 5883d51
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 50 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: raer
Type: Package
Title: RNA editing tools in R
Version: 0.99.8
Version: 0.99.9
Authors@R: c(
person("Kent", "Riemondy", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-0750-1273")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# raer 0.99.9

* The `genomic-unstranded` option for the `library-type` argument in `FilterParam()` has been renamed to `unstranded`, and the `unstranded` option has been removed.

# raer 0.99.8

* Function arguments involving a fasta file have been renamed to all be `fasta`
Expand Down
14 changes: 7 additions & 7 deletions R/calc_AEI.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#' calculating the AEI, typically ALU repeats.
#' @param txdb A [TxDb] object, if supplied, will be used to subset the alu_ranges
#' to those found overlapping genes. Alternatively a [GRanges] object with gene
#' coordinates. If the `library_type` specified by
#' `FilterParam`, is `unstranded` or `genomic-unstranded`, then the [TxDb] will
#' coordinates. If the `library_type`, specified by
#' `FilterParam`, is `unstranded` then the [TxDb] will
#' be used to correct the strandness relative to the reference and is a required
#' parameter.
#' @param snp_db either a [SNPlocs], [GPos], or [GRanges] object. If supplied,
Expand Down Expand Up @@ -92,11 +92,11 @@ calc_AEI <- function(bamfiles,

genes_gr <- NULL
alu_bed_fn <- NULL
if (param@library_type %in% c(0, 3)) {
if (param@library_type == 0) {
if (is.null(txdb)) {
cli::cli_abort("txdb required for processing unstranded data")
}
param@library_type <- 0L

if (is(txdb, "TxDb")) {
genes_gr <- suppressWarnings(GenomicFeatures::genes(txdb))
} else {
Expand Down Expand Up @@ -364,14 +364,14 @@ get_overlapping_snps <- function(gr,
#'
#' @description Gene annotations are used to infer the likely strand of editing
#' sites. This function will operate on unstranded datasets which have been
#' processed using "genomic-unstranded" library type which reports variants
#' processed using "unstranded" library type which reports variants
#' with respect to the + strand for all sites. The strand of the editing site
#' will be assigned the strand of overlapping features in the `genes_gr`
#' object. Sites with no-overlap, or overlapping features with conflicting
#' strands (+ and -) will be removed.
#'
#' @param rse RangedSummarizedExperiment object containing editing sites processed with
#' "genomic-unstranded" setting
#' "unstranded" setting
#' @param genes_gr GRanges object containing reference features to annotate the
#' strand of the editing sites.
#'
Expand All @@ -383,7 +383,7 @@ get_overlapping_snps <- function(gr,
#'
#' bamfn <- raer_example("SRR5564269_Aligned.sortedByCoord.out.md.bam")
#' fafn <- raer_example("human.fasta")
#' fp <- FilterParam(library_type = "genomic-unstranded")
#' fp <- FilterParam(library_type = "unstranded")
#' rse <- pileup_sites(bamfn, fafn, param = fp)
#'
#' genes <- GRanges(c(
Expand Down
18 changes: 7 additions & 11 deletions R/pileup.R
Original file line number Diff line number Diff line change
Expand Up @@ -628,21 +628,18 @@ setMethod(show, "FilterParam", function(object) {
})


.encode_libtype <- function(library_type = c("genomic-unstranded",
.encode_libtype <- function(library_type = c("unstranded",
"fr-first-strand",
"fr-second-strand",
"unstranded"),
"fr-second-strand"),
n_files) {
# encode libtype as integer
# 0 = genomic-unstranded all reads on + strand
# 0 = unstranded all reads on + strand
# 1 = fr-first-strand strand based on R1/antisense, R2/sense
# 2 = fr-second-strand strand based on R1/sense, R2/antisense
# 3 = unstranded strand based on alignment
lib_values <- c(
"genomic-unstranded",
"unstranded",
"fr-first-strand",
"fr-second-strand",
"unstranded"
"fr-second-strand"
)
lib_code <- match(library_type, lib_values)
if (any(is.na(lib_code))) {
Expand Down Expand Up @@ -712,9 +709,8 @@ setMethod(show, "FilterParam", function(object) {
#' @param min_mapq minimum required MAPQ score. Values for each input BAM file
#' can be provided as a vector.
#' @param library_type read orientation, one of `fr-first-strand`,
#' `fr-second-strand`, `unstranded`, and `genomic-unstranded`. Unstranded library
#' type will be reported based on read alignment. genomic-unstranded will report
#' all variants w.r.t the + strand. Values for each
#' `fr-second-strand`, and `unstranded`. Unstranded library
#' type will be reported with variants w.r.t the + strand. Values for each
#' input BAM file can be provided as a vector.
#' @param only_keep_variants if TRUE, then only variant sites will be reported
#' (FALSE by default). Values for each input BAM file can be provided as a vector.
Expand Down
4 changes: 2 additions & 2 deletions man/calc_AEI.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/correct_strand.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/pileup_sites.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions src/plp_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,6 @@ int invert_read_orientation(bam1_t* b, int libtype) {
invert = 1;
}
}
} else if (libtype == 3) {
if (is_neg) {
invert = 1;
}
} else {
invert = -1;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_aei.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test_that("calc_aei basic options work", {
ssr3_aei <- pc[pc$chrom == "SPCS3" & startsWith(pc$allele, "A_"), ]
expect_true(all(ssr3_aei[c("alt", "ref")] == 0))

fp <- FilterParam(library_type = "genomic-unstranded")
fp <- FilterParam(library_type = "unstranded")
expect_error(calc_AEI(bams, fafn, mock_alu_ranges, param = fp))

us_aei <- calc_AEI(bams, fafn, mock_alu_ranges, mock_genes, param = fp)
Expand Down
28 changes: 11 additions & 17 deletions tests/testthat/test_pileup_sites.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test_that("n-bam pileup works", {
res <- pileup_sites(c(bamfn, bamfn), fafn, sites,
param = FilterParam(library_type = c(
"fr-first-strand",
"genomic-unstranded"
"unstranded"
))
)
expect_equal(dim(res), c(214, 2))
Expand Down Expand Up @@ -137,15 +137,10 @@ test_that("library types are respected", {
expect_true(all(strand(res[seqnames(res) == "DHFR"]) == "+"))
expect_true(all(strand(res[seqnames(res) == "SPCS3"]) == "-"))

res <- pileup_sites(bamfn, fafn,
param = FilterParam(library_type = "genomic-unstranded")
)
expect_true(all(strand(res) == "+"))

res <- pileup_sites(bamfn, fafn,
param = FilterParam(library_type = "unstranded")
)
expect_true(all(strand(res) %in% c("+", "-")))
expect_true(all(strand(res) == "+"))

expect_error(pileup_sites(bamfn, fafn, sites,
param = FilterParam(library_type = "unknown-string")
Expand Down Expand Up @@ -194,9 +189,8 @@ check_nRef_calc <- function(input, nts_in = nts) {

test_that("pileup check nRef and nAlt", {
strds <- c(
"fr-first-strand", "fr-second-strand",
"unstranded", "genomic-unstranded"
)
"fr-first-strand", "fr-second-strand","unstranded"
)

for (strd in strds) {
res <- pileup_sites(bamfn, fafn,
Expand Down Expand Up @@ -476,7 +470,7 @@ test_that("poor quality reads get excluded with read_bqual", {
res_no_filter <- pileup_sites(bamfn, fafn,
param = FilterParam(
min_base_quality = 0L,
library_type = c("genomic-unstranded")
library_type = c("unstranded")
)
)

Expand All @@ -496,7 +490,7 @@ test_that("poor quality reads get excluded with read_bqual", {
param = FilterParam(
read_bqual = bqual_cutoff,
min_base_quality = 0L,
library_type = c("genomic-unstranded")
library_type = c("unstranded")
)
)

Expand All @@ -517,7 +511,7 @@ test_that("poor quality reads get excluded with read_bqual", {
test_that("sites within short splice overhangs can be excluded", {
# 5 spliced reads, 2 unspliced
fp <- FilterParam(
library_type = "genomic-unstranded",
library_type = "unstranded",
min_splice_overhang = 0,
min_base_quality = 0
)
Expand All @@ -527,7 +521,7 @@ test_that("sites within short splice overhangs can be excluded", {

# excludes 1 read 5' of splice site (SRR5564269.2688337, cigar 51M120N100M)
fp <- FilterParam(
library_type = "genomic-unstranded",
library_type = "unstranded",
min_splice_overhang = 52,
min_base_quality = 0
)
Expand All @@ -536,7 +530,7 @@ test_that("sites within short splice overhangs can be excluded", {
expect_equal(as.vector(assay(res, "nRef")), 6)

fp <- FilterParam(
library_type = "genomic-unstranded",
library_type = "unstranded",
min_splice_overhang = 0,
min_base_quality = 0
)
Expand All @@ -546,7 +540,7 @@ test_that("sites within short splice overhangs can be excluded", {

# excludes 1 read 3' of splice site (SRR5564269.224850, cigar 73M120N78M)
fp <- FilterParam(
library_type = "genomic-unstranded",
library_type = "unstranded",
min_splice_overhang = 79,
min_base_quality = 0
)
Expand All @@ -556,7 +550,7 @@ test_that("sites within short splice overhangs can be excluded", {

# excludes all 5 spliced reads
fp <- FilterParam(
library_type = "genomic-unstranded",
library_type = "unstranded",
min_splice_overhang = 101,
min_base_quality = 0
)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/novel-sites.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fp <- FilterParam(
min_depth = 1,
min_base_quality = 30,
min_mapq = c(255, 30),
library_type = c("fr-first-strand", "genomic-unstranded"),
library_type = c("fr-first-strand", "unstranded"),
trim_5p = 5,
trim_3p = 5,
indel_dist = 4,
Expand Down

0 comments on commit 5883d51

Please sign in to comment.