Skip to content

Commit

Permalink
Fixed manual and more bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mevers committed Oct 9, 2019
1 parent 7661ce9 commit d17eb14
Show file tree
Hide file tree
Showing 18 changed files with 63 additions and 274 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^doc$
^Meta$
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ data/tx_hg38.RData
.Rproj.user
*.RData
*.Rproj
inst/doc
doc
Meta
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Depends:
R (>= 3.5.0)
Suggests:
knitr,
testthat
testthat,
rmarkdown
License: GPL-3 | file LICENSE
LazyData: false
RoxygenNote: 6.1.1
Expand Down
6 changes: 3 additions & 3 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ DownsampleTxLoc <- function(txLoc1, txLoc2, seed = NULL) {
if (!is.null(seed)) set.seed(seed)

# Subsample
loci <- mapply(
loci <- Map(
function(loci1, loci2) loci1[sample.int(nrow(loci1), nrow(loci2)), ],
GetLoci(txLoc1),
GetLoci(txLoc2))
Expand Down Expand Up @@ -342,7 +342,7 @@ SubsampleTxLoc <- function(txLoc, fractions, seed = NULL) {
if (!is.null(seed)) set.seed(seed)

# Subsample
loci <- mapply(
loci <- Map(
function(loci, frac) {
idx <- sample.int(nrow(loci), round(frac * nrow(loci)))
loci[idx, ]
Expand Down Expand Up @@ -437,7 +437,7 @@ GetRelDistNearest <- function(lst1, lst2) {
stopifnot(identical(names(lst1), names(lst2)))

# Calculate nearest distances from start
lst <- mapply(
lst <- Map(
function(gr1, gr2) {

# Collapse range of gr1 and gr2 to the start coordinate
Expand Down
47 changes: 26 additions & 21 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,16 @@ SmartMap.ToTx <- function(gr,
#'
#' @param gr A \code{GRanges} object; specifies the list of of genomic features
#' to be mapped.
#' @param id A character string; specifies a name for loci from \code{gr}; if
#' \code{NULL} then \code{id = ""}; default is \code{NULL}.
#' @param refGenome A character string; specifies a specific reference genome
#' assembly version based on which the matching transcriptome is loaded;
#' @param id A \code{character} string; specifies a name for loci from
#' \code{gr}; if \code{NULL} then \code{id = ""}; default is \code{NULL}.
#' @param refGenome A \code{character} string; specifies a specific reference
#' genome assembly version based on which the matching transcriptome is loaded;
#' default is \code{"hg38"}.
#' @param ignore.strand A logical scalar; if \code{TRUE} strand information is
#' ignored when mapping genome coordinates to transcript coordinates; default
#' is \code{FALSE}.
#' @param ignore.strand A \code{logical} scalar; if \code{TRUE} strand
#' information is ignored when mapping genome coordinates to transcript
#' coordinates; default is \code{FALSE}.
#' @param showPb A \code{logical} scalar; if \code{TRUE} show a progress bar;
#' default is \code{TRUE}.
#'
#' @return A \code{txLoc} object. See 'Details'.
#'
Expand All @@ -172,7 +174,8 @@ SmartMap.ToTx <- function(gr,
SmartMap <- function(gr,
id = NULL,
refGenome = "hg38",
ignore.strand = FALSE) {
ignore.strand = FALSE,
showPb = TRUE) {

# Sanity check
CheckClass(gr, "GRanges")
Expand Down Expand Up @@ -203,7 +206,7 @@ SmartMap <- function(gr,
loci <- SmartMap.ToTx(
gr, txBySec, seqBySec, geneXID,
ignore.strand = ignore.strand,
showPb = TRUE)
showPb = showPb)

# Return `txLoc` object
new("txLoc",
Expand Down Expand Up @@ -254,17 +257,17 @@ SmartMap <- function(gr,
#' null sites using this approach.
#'
#' @param txLoc A \code{txLoc} object.
#' @param id A character string; identifier for null sites; if \code{NULL} then
#' \code{id = "null"}; default is \code{NULL}.
#' @param method A character string; specifies the method used to the generate
#' null distribution; if \code{method == "ntAbund"} the position of all
#' nucleotides specified by \code{nt} will be used as null sites; if
#' @param id A \code{character} string; identifier for null sites; if
#' \code{NULL} then \code{id = "null"}; default is \code{NULL}.
#' @param method A \code{character} string; specifies the method used to the
#' generate null distribution; if \code{method == "ntAbund"} the position of
#' all nucleotides specified by \code{nt} will be used as null sites; if
#' \code{method == "perm"} (DEPRECATED, see 'Details') then null sites will be
#' generated by uniform-randomly shuffling candidatepositions from \code{locus}
#' within the corresponding transcript region; default is \code{"ntAbund"}.
#' @param nt A single character; if \code{method == "ntAbund"}, use \code{nt}
#' to derive distribution of null sites.
#' @param showPb A logical scalar; if \code{TRUE} show a progress
#' @param nt A single \code{character}; if \code{method == "ntAbund"}, use
#' \code{nt} to derive distribution of null sites.
#' @param showPb A \code{logical} scalar; if \code{TRUE} show a progress
#' bar; default is \code{TRUE}.
#'
#' @return A \code{txLoc} object. See 'Details'.
Expand Down Expand Up @@ -337,7 +340,7 @@ GenerateNull <- function(txLoc,
pb <- txtProgressBar(
max = length(GetRegions(txLoc)), style = 3, width = 60)

loci <- mapply(
loci <- Map(
function(i, region) {

# Update progress bar
Expand Down Expand Up @@ -470,7 +473,7 @@ GetGC <- function(txLoc, flank = 10) {

# Extract subsequences
# We use `subseq` instead of `substr` as it is more performant
seqWindow <- as(mapply(
seqWindow <- as(Map(
function(seq, x) subseq(seq, start = x[1], end = x[2]),
seqRegion, windows), "DNAStringSet")

Expand Down Expand Up @@ -643,7 +646,7 @@ GetSplicingSites <- function(refGenome = "hg38", filter = c("CDS", "5'UTR")) {
# corresponding to splicing donor and acceptor sites
# Add score and id metadata columns to make sure that we are
# consistent with the BED6 format
junct <- unlist(as(mapply(
junct <- unlist(as(Map(
function(fix, type) {
eej <- resize(
junct, width = 1, fix = fix, ignore.strand = F, use.names = T)
Expand Down Expand Up @@ -895,7 +898,9 @@ GetDistanceStartStop <- function(txLoc, refGenome = "hg38") {
#' that are allowed during the motif matching; default is 0.
#' @param showPb A logical scalar; if \code{TRUE} show a progress bar; default
#' is \code{TRUE}.

#'
#' @return A \code{txLoc} object.
#'
#' @author Maurits Evers, \email{maurits.evers@@anu.edu.au}
#'
#' @import GenomicRanges IRanges
Expand Down
8 changes: 4 additions & 4 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ PlotSpatialEnrichment <- function(txLoc.pos,
breaks <- seq(0, posMax, by = binWidth)

# Plot
invisible(mapply(
invisible(Map(
function(loci.pos, loci.neg, region) {

# Store site positions
Expand Down Expand Up @@ -546,7 +546,7 @@ PlotSpatialEnrichment <- function(txLoc.pos,
ctsMat <- as.matrix(rbind(ctsPos, ctsNeg))
rownames(ctsMat) <- c(GetId(txLoc.pos), GetId(txLoc.neg))
title <- sprintf(
"%s\nN(%s) = %i, N(%s) = %i, bw = %i nt, window = %i nt",
"%s\nN(%s) = %i, N(%s) = %i\nbw = %i nt, window = %i nt",
region,
GetId(txLoc.pos),
sum(ctsPos),
Expand Down Expand Up @@ -1147,7 +1147,7 @@ PlotSeqLogo <- function(txLoc, flank = 5, ylim = c(0, 2)) {
par(mfrow = c(ceiling(length(GetRegions(txLoc)) / 2), 2))
}

mapply(
invisible(Map(
function(locus, region) {

# Define window coordinates
Expand Down Expand Up @@ -1202,6 +1202,6 @@ PlotSeqLogo <- function(txLoc, flank = 5, ylim = c(0, 2)) {
bty = "n")

},
GetLoci(txLoc), GetRegions(txLoc))
GetLoci(txLoc), GetRegions(txLoc)))

}
Binary file removed doc/RNAModR-manual.pdf
Binary file not shown.
Empty file removed doc/readme.txt
Empty file.
16 changes: 8 additions & 8 deletions man/GenerateNull.Rd

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

35 changes: 0 additions & 35 deletions man/GetLocus.MapFromTranscripts.Rd

This file was deleted.

40 changes: 0 additions & 40 deletions man/GetMFE.Rd

This file was deleted.

3 changes: 3 additions & 0 deletions man/GetMotifLoc.Rd

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

27 changes: 0 additions & 27 deletions man/PlotOverlap.Rd

This file was deleted.

37 changes: 0 additions & 37 deletions man/PlotTxSecLength.Rd

This file was deleted.

Loading

0 comments on commit d17eb14

Please sign in to comment.