Commit 633c8f0a authored by aditya.bhagwat's avatar aditya.bhagwat
Browse files

BiocCheck edits

parent 3ba0892f
......@@ -28,7 +28,6 @@ export(find_spacers)
export(genefile_to_granges)
export(genes_to_granges)
export(gr2dt)
export(has_been_indexed)
export(index_genome)
export(index_targets)
export(match_seqs)
......
......@@ -205,54 +205,47 @@ head_tail <- function(x, n){
}
prepare_plot_intervals <- function(gr, xref, y, nperchrom, nchrom){
# Comply
edge <- targetname <- xstart <- xend <- width <- NULL
targetstart <- targetend <- xtargetstart <- xtargetend <- NULL
extstart <- primer <- revtranscript <- extension <- tmp <- NULL
edge <- targetname <- xstart <- xend <- width <- NULL
targetstart <- targetend <- xtargetstart <- xtargetend <- NULL
extstart <- primer <- revtranscript <- extension <- tmp <- NULL
# Prepare data.table. Select chromosomes/targets to plot.
plotdt <- data.table::as.data.table(gr) %>% cbind(names = names(gr))
plotdt %<>% extract(order(seqnames, start))
plotdt$seqnames %<>% droplevels()
headtailchroms <- head_tail(levels(plotdt$seqnames), nchrom)
plotdt %<>% extract(headtailchroms, on = 'seqnames')
plotdt$seqnames %<>% factor(headtailchroms)
plotdt %<>% extract( # targets
, .SD[targetname %in% head_tail(unique(targetname), nperchrom)],
by = 'seqnames')
plotdt <- data.table::as.data.table(gr) %>% cbind(names = names(gr))
plotdt %<>% extract(order(seqnames, start))
plotdt$seqnames %<>% droplevels()
headtailchroms <- head_tail(levels(plotdt$seqnames), nchrom)
plotdt %<>% extract(headtailchroms, on = 'seqnames')
plotdt$seqnames %<>% factor(headtailchroms)
plotdt %<>% extract( # targets
, .SD[targetname %in% head_tail(unique(targetname), nperchrom)],
by = 'seqnames')
# Main ranges
plotdt %>% extract(, y := min(start), by = y)
plotdt %>% extract(, y := factor(format(y, big.mark = " ")))
plotdt %>% extract(, xstart := start-min(start), by = xref)
plotdt %>% extract(, xend := xstart + width)
plotdt %>% extract(, y := min(start), by = y)
plotdt %>% extract(, y := factor(format(y, big.mark = " ")))
plotdt %>% extract(, xstart := start-min(start), by = xref)
plotdt %>% extract(, xend := xstart + width)
# Target marks
if (all(c('targetstart', 'targetend') %in% names(mcols(gr)))){
plotdt %>% extract(, xtargetstart := xstart + targetstart-start)
plotdt %>% extract(, xtargetend := xend + targetend-end )
}
if (all(c('targetstart', 'targetend') %in% names(mcols(gr)))){
plotdt %>% extract(, xtargetstart := xstart + targetstart-start)
plotdt %>% extract(, xtargetend := xend + targetend-end )
}
# Extensions
if ('extension' %in% names(mcols(gr))){
plotdt %>% extract(strand=='+', extstart := xstart+18-nchar(primer)[1])
plotdt %>% extract(strand=='-',
extstart := xend-16-(nchar(revtranscript)[1]-1))
plotdt %>% extract(, extend := extstart + nchar(extension)[1]-1)
}
if ('extension' %in% names(mcols(gr))){
plotdt %>% extract(strand=='+', extstart := xstart+18-nchar(primer)[1])
plotdt %>% extract(strand=='-',
extstart := xend-16-(nchar(revtranscript)[1]-1))
plotdt %>% extract(, extend := extstart + nchar(extension)[1]-1)
}
# Flip for arrow direction
plotdt %>% extract(strand=='-', tmp := xend)
plotdt %>% extract(strand=='-', xend := xstart)
plotdt %>% extract(strand=='-', xstart := tmp)
if ('extension' %in% names(mcols(gr))){
plotdt %>% extract(strand=='+', tmp := extend)
plotdt %>% extract(strand=='+', extend := extstart)
plotdt %>% extract(strand=='+', extstart := tmp)
}
plotdt %>% extract(, tmp := NULL)
plotdt %>% extract(strand=='-', tmp := xend)
plotdt %>% extract(strand=='-', xend := xstart)
plotdt %>% extract(strand=='-', xstart := tmp)
if ('extension' %in% names(mcols(gr))){
plotdt %>% extract(strand=='+', tmp := extend)
plotdt %>% extract(strand=='+', extend := extstart)
plotdt %>% extract(strand=='+', extstart := tmp)
}
plotdt %>% extract(, tmp := NULL)
# Return
plotdt
plotdt
}
......@@ -374,11 +374,12 @@ double_flank <- function(
up$set <- 'upstream flank'
dn$set <- 'downstream flank'
allgr <- c(gr, up, dn)
allgr$set %<>% factor(c('original', 'upstream flank', 'downstream flank'))
allgr$set %<>% factor(
c('original', 'upstream flank', 'downstream flank'))
txt <- sprintf('\t\t%d flank ranges: %d up + %d down',
length(newgr), length(up), length(dn))
print(plot_intervals(
allgr, linetype_var = linetype_var, title = txt, y = 'targetname', ...))
print(plot_intervals(allgr, linetype_var = linetype_var, title = txt,
y = 'targetname', ...))
}
# Return
......
......@@ -18,20 +18,21 @@ OUTDIR <- '~/multicrisprout'
spacer_fasta <- function(outdir = OUTDIR){
paste0(outdir, '/spacers.fa') }
#' Has been indexed?
#' @param bsgenome BSgenome
#' @param indexedgenomesdir directory with indexed genomes
#' @examples
#' bsgenome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38
#' has_been_indexed(bsgenome)
#' @export
has_been_indexed <- function(bsgenome, indexedgenomesdir = INDEXEDGENOMESDIR){
dir.exists(genome_dir(bsgenome = bsgenome))
}
# Has been indexed?
# @param bsgenome BSgenome
# @param indexedgenomesdir directory with indexed genomes
# @examples
# bsgenome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38
# has_been_indexed(bsgenome)
# @export
# has_been_indexed <- function(bsgenome, indexedgenomesdir = INDEXEDGENOMESDIR){
# dir.exists(genome_dir(bsgenome = bsgenome))
# }
# multicrispr_bucket <- function(){
# Sys.setenv('AWS_S3_ENDPOINT' = 's3.mpi-bn.mpg.de')
# contents <- aws.s3::get_bucket(bucket = 'data-multicrispr-2020', region="")
# contents <- aws.s3::get_bucket(
# bucket = 'data-multicrispr-2020', region="")
# bsgenomes <- unname(vapply(contents, extract2, character(1), 'Key'))
# Sys.setenv('AWS_S3_ENDPOINT' = 's3.amazonaws.com')
# }
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/07_filter_specific.R
\name{has_been_indexed}
\alias{has_been_indexed}
\title{Has been indexed?}
\usage{
has_been_indexed(bsgenome, indexedgenomesdir = INDEXEDGENOMESDIR)
}
\arguments{
\item{bsgenome}{BSgenome}
\item{indexedgenomesdir}{directory with indexed genomes}
}
\description{
Has been indexed?
}
\examples{
bsgenome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38
has_been_indexed(bsgenome)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment