Commit 18313f16 authored by aditya.bhagwat's avatar aditya.bhagwat
Browse files

Satisfy BiocCheck()

parent 1d8deb0c
......@@ -34,13 +34,13 @@ Imports:
GenomeInfoDb,
GenomicFeatures,
GenomicRanges,
IRanges,
ggplot2,
grid,
Gviz,
karyoploteR,
magrittr,
methods,
parallel,
plyranges,
Rbowtie,
reticulate,
......@@ -54,6 +54,7 @@ Suggests:
BSgenome.Hsapiens.UCSC.hg38,
BSgenome.Mmusculus.UCSC.mm10,
ensembldb,
IRanges,
knitr,
rmarkdown,
testthat,
......
......@@ -20,7 +20,7 @@ uniquify <- function(x){
dt <- data.table::data.table(x = x)
dt[, N := .N, by='x']
dt[N==1, xunique := x]
dt[N>1, xunique := paste0(x, '_', 1:.N), by = 'x']
dt[N>1, xunique := paste0(x, '_', seq_len(.N)), by = 'x']
dt[, xunique]
}
......@@ -48,6 +48,7 @@ name_uniquely <- function(gr, prefix = 'x'){
#' @param dt data.table
#' @param seqinfo \code{\link[GenomeInfoDb]{Seqinfo-class}}
#' @aliases dt2gr
#' @return data.table (gr2dt) or GRanges (dt2gr)
#' @examples
#' bsgenome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38
#' gr <- char_to_granges(c(PRNP = 'chr20:4699600:+', # snp
......
......@@ -145,17 +145,9 @@ to_megabase <- function(y){
#'
#' @export
plot_intervals <- function(
gr,
xref = 'targetname',
y = 'names',
nperchrom = 1,
color_var = 'targetname',
facet_var = 'seqnames',
linetype_var = NULL,
size_var = NULL,
alpha_var = NULL,
title = NULL,
scales = 'free'
gr, xref = 'targetname', y = 'names', nperchrom = 1,
color_var = 'targetname', facet_var = 'seqnames', linetype_var = NULL,
size_var = NULL, alpha_var = NULL, title = NULL, scales= 'free'
){
# Comply
edge <- targetname <- NULL
......@@ -167,46 +159,46 @@ plot_intervals <- function(
contig <- .N <- .SD <- seqnames <- start <- NULL
strand <- tmp <- width <- xstart <- xend <- . <- NULL
# Identify contigs and order on them
# gr$contig <- GenomicRanges::findOverlaps(
# gr, maxgap = 30, select = 'first', ignore.strand = TRUE)
# gr %<>% extract(order(.$contig))
# Prepare plotdt
plotdt <- prepare_plot_intervals(gr, xref, y, nperchrom)
# Core Ranges
p <-ggplot( plotdt,
aes_string(
x = 'xstart', xend = 'xend', y = 'y', yend = 'y',
color = color_var, linetype = linetype_var,
size = size_var, alpha = alpha_var)) +
aes_string(x = 'xstart', xend = 'xend', y = 'y', yend = 'y',
color = color_var, linetype = linetype_var,
size = size_var, alpha = alpha_var)) +
facet_wrap(facet_var, scales = scales) +
geom_segment(
arrow = arrow(length = unit(0.1, "inches")))
geom_segment(arrow = arrow(length = unit(0.1, "inches")))
# Targets
if (all(c('targetstart', 'targetend') %in% names(mcols(gr)))){
p <-p +
geom_point(aes_string(
x = 'xtargetstart', y = 'y'), shape = '|', size = 4) +
geom_point(aes_string(
x = 'xtargetend', y = 'y'), shape = '|', size = 4)
p <-p + geom_point(aes_string(
x = 'xtargetstart', y = 'y'), shape = '|', size = 4) +
geom_point(aes_string(
x = 'xtargetend', y = 'y'), shape = '|', size = 4)
}
# Extensions
if ('extension' %in% names(mcols(gr))){
p <-p + geom_segment(aes_string(x='extstart', xend='extend', size = NULL),
linetype = 'dotted',
p <-p + geom_segment(
aes_string( x = 'extstart', xend = 'extend', size = NULL),
linetype = 'dotted',
arrow = arrow(length = unit(0.1, "inches")))
}
p <- p + theme_bw() + xlab(NULL) + ylab(NULL) + ggtitle(title)
# Return
# print(p)
p
p # print(p)
}
# Identify contigs and order on them
# gr$contig <- GenomicRanges::findOverlaps(
# gr, maxgap = 30, select = 'first', ignore.strand = TRUE)
# gr %<>% extract(order(.$contig))
prepare_plot_intervals <- function(gr, xref, y, nperchrom){
# Comply
......@@ -218,7 +210,8 @@ prepare_plot_intervals <- function(gr, xref, y, nperchrom){
plotdt <- data.table::as.data.table(gr) %>% cbind(names = names(gr))
plotdt %<>% extract(order(seqnames, start))
head_tail <- function(x, n=nperchrom) x [ x %in% c(head(x, n), tail(x, n)) ]
plotdt %<>% extract(, edge := targetname %in% head_tail(unique(targetname)), by = 'seqnames')
plotdt %<>% extract(, edge := targetname %in% head_tail(unique(targetname)),
by = 'seqnames')
plotdt %<>% extract(edge==TRUE)
plotdt %>% extract(, y := min(start), by = y)
plotdt %>% extract(, y := factor(format(y, big.mark = " ")))
......@@ -234,8 +227,9 @@ prepare_plot_intervals <- function(gr, xref, y, nperchrom){
# 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)
plotdt %>% extract(strand=='-',
extstart := xend-16-(nchar(revtranscript)[1]-1))
plotdt %>% extract(, extend := extstart + nchar(extension)[1]-1)
}
# Flip for arrow direction
......
......@@ -139,13 +139,13 @@ bed_to_granges <- function(
# Order
if (do_order) gr %<>% sort(ignore.strand = TRUE)
#%<>% extract( order(seqnames(.), start(.)))
#%<>% extract( order(seqnames(.), start(.)))
# Record
names(gr) <- gr$targetname <- make_unique_names(gr, 'T')
gr$targetstart <- GenomicRanges::start(gr)
gr$targetend <- GenomicRanges::end(gr)
names(gr) <- gr$targetname <- make_unique_names(gr, 'T')
gr$targetstart <- GenomicRanges::start(gr)
gr$targetend <- GenomicRanges::end(gr)
# Return
gr
}
......@@ -167,11 +167,11 @@ bed_to_granges <- function(
#' @seealso \code{\link{bed_to_granges}}, \code{\link{genes_to_granges}}
#' @export
char_to_granges <- function(x, bsgenome){
gr <- GenomicRanges::GRanges(x, seqinfo = BSgenome::seqinfo(bsgenome))
names(gr) <- gr$targetname <- make_unique_names(gr, 'T')
gr$targetstart <- GenomicRanges::start(gr)
gr$targetend <- GenomicRanges::end(gr)
gr
gr <- GenomicRanges::GRanges(x, seqinfo = BSgenome::seqinfo(bsgenome))
names(gr) <- gr$targetname <- make_unique_names(gr, 'T')
gr$targetstart <- GenomicRanges::start(gr)
gr$targetend <- GenomicRanges::end(gr)
gr
}
......@@ -232,10 +232,10 @@ genes_to_granges <- function(
if (plot) plot_karyogram(gr)
# Record
names(gr) <- gr$targetname <- make_unique_names(gr, 'T')
gr$targetstart <- GenomicRanges::start(gr)
gr$targetend <- GenomicRanges::end(gr)
names(gr) <- gr$targetname <- make_unique_names(gr, 'T')
gr$targetstart <- GenomicRanges::start(gr)
gr$targetend <- GenomicRanges::end(gr)
# Return
gr
}
......
......@@ -80,20 +80,20 @@ summarize_loci <- function(gr){
#' @examples
#' # PE example
#' #-----------
#' require(magrittr)
#' bsgenome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38
#' gr <- char_to_granges(c(PRNP = 'chr20:4699600:+', # snp
#' require(magrittr)
#' bsgenome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38
#' gr <- char_to_granges(c(PRNP = 'chr20:4699600:+', # snp
#' HBB = 'chr11:5227002:-', # snp
#' HEXA = 'chr15:72346580-72346583:-', # del
#' CFTR = 'chr7:117559593-117559595:+'),# ins
#' bsgenome = bsgenome)
#' gr %>% up_flank(-22, -1, plot = TRUE, facet_var = c('targetname', 'seqnames'))
#' gr %>% up_flank(-22, -1, plot = TRUE, strandaware = FALSE)
#' gr %>% down_flank(+1, +22, plot = TRUE)
#' gr %>% down_flank(+1, +22, plot = TRUE, strandaware = FALSE)
#' gr %>% extend(-10, +20, plot = TRUE)
#' gr %>% extend(-10, +20, plot = TRUE, strandaware = FALSE)
#'
#' gr %>% up_flank( -22, -1, plot=TRUE, facet_var=c('targetname', 'seqnames'))
#' gr %>% up_flank( -22, -1, plot=TRUE, strandaware=FALSE)
#' gr %>% down_flank(+1, +22, plot=TRUE)
#' gr %>% down_flank(+1, +22, plot=TRUE, strandaware=FALSE)
#' gr %>% extend( -10, +20, plot=TRUE)
#' gr %>% extend( -10, +20, plot=TRUE, strandaware=FALSE)
#'
#' # TFBS example
#' #-------------
#' bedfile <- system.file('extdata/SRF.bed', package='multicrispr')
......@@ -103,15 +103,8 @@ summarize_loci <- function(gr){
#' gr %>% down_flank(plot = TRUE)
#' @export
up_flank <- function(
gr,
start = -200,
end = -1,
strandaware = TRUE,
bsgenome = NULL,
verbose = FALSE,
plot = FALSE,
linetype_var = 'set',
...
gr, start = -200, end = -1, strandaware = TRUE, bsgenome = NULL,
verbose = FALSE, plot = FALSE, linetype_var = 'set', ...
){
# Assert
assert_is_all_of(gr, 'GRanges')
......@@ -124,17 +117,18 @@ up_flank <- function(
shift <- sprintf('(%s%d,%s%d)',
csign(start), abs(start), csign(end), abs(end))
txt <- sprintf('\t\t%d%supstream %s flanks',
length(newgr),
ifelse(!strandaware, ' (strandagnostic) ', ' '),
shift)
length(newgr),
ifelse(!strandaware, ' (strandagnostic) ', ' '),
shift)
# Flank
GenomicRanges::start(newgr) <- GenomicRanges::start(gr) + start
GenomicRanges::end(newgr) <- GenomicRanges::start(gr) + end
if (strandaware){
idx <- as.logical(strand(newgr)=='-')
GenomicRanges::end( newgr)[idx] <- GenomicRanges::end(gr)[idx] - start # do not switch these lines
GenomicRanges::start(newgr)[idx] <- GenomicRanges::end(gr)[idx] - end # to avoid integrity errors
# do not switch following lines to avoid integrity errors !
GenomicRanges::end( newgr)[idx] <- GenomicRanges::end(gr)[idx] - start
GenomicRanges::start(newgr)[idx] <- GenomicRanges::end(gr)[idx] - end
}
# Add seq
......@@ -149,7 +143,8 @@ up_flank <- function(
newgr$set <- 'upstream flanks'
allgr <- c(gr, newgr)
allgr$set %<>% factor(c('original', 'upstream flanks'))
print(plot_intervals(allgr, linetype_var = linetype_var, ..., title = txt))
print(plot_intervals(
allgr, linetype_var = linetype_var, ..., title = txt))
newgr$set <- NULL
}
if (verbose) message(txt)
......@@ -160,15 +155,8 @@ up_flank <- function(
#' @rdname up_flank
#' @export
down_flank <- function(
gr,
start = 1,
end = 200,
strandaware = TRUE,
bsgenome = NULL,
verbose = FALSE,
plot = FALSE,
linetype_var = 'set',
...
gr, start = 1, end = 200, strandaware = TRUE, bsgenome = NULL,
verbose = FALSE, plot = FALSE, linetype_var = 'set', ...
){
# Assert
assert_is_any_of(gr, 'GRanges')
......@@ -181,17 +169,17 @@ down_flank <- function(
shift <- sprintf('(%s%d,%s%d)',
csign(start), abs(start), csign(end), abs(end))
txt <- sprintf('\t\t%d%sdownstream %s flanks',
length(newgr),
ifelse(!strandaware, ' (strandagnostic) ', ' '),
shift)
length(newgr),
ifelse(!strandaware, ' (strandagnostic) ', ' '),
shift)
# Flank
GenomicRanges::end(newgr) <- GenomicRanges::end(gr) + end
GenomicRanges::start(newgr) <- GenomicRanges::end(gr) + start
if (strandaware){
idx <- as.logical(strand(newgr)=='-')
GenomicRanges::start(newgr)[idx] <- GenomicRanges::start(gr)[idx] - end
GenomicRanges::end( newgr)[idx] <- GenomicRanges::start(gr)[idx] - start
idx <- as.logical(strand(newgr)=='-')
GenomicRanges::start(newgr)[idx] <- GenomicRanges::start(gr)[idx]-end
GenomicRanges::end( newgr)[idx] <- GenomicRanges::start(gr)[idx]-start
}
# Add seq
......@@ -206,9 +194,10 @@ down_flank <- function(
newgr$set <- 'downstream flanks'
allgr <- c(gr, newgr)
allgr$set %<>% factor(c('original', 'downstream flanks'))
print(plot_intervals(allgr, linetype_var = linetype_var, ..., title=txt))
print(plot_intervals(
allgr, linetype_var = linetype_var, ..., title=txt))
newgr$set <- NULL
}
}
if (verbose) message(txt)
newgr
}
......@@ -217,15 +206,8 @@ down_flank <- function(
#' @rdname up_flank
#' @export
extend <- function(
gr,
start = -22,
end = 22,
strandaware = TRUE,
bsgenome = NULL,
verbose = FALSE,
plot = FALSE,
linetype_var = 'set',
...
gr, start = -22, end = 22, strandaware = TRUE, bsgenome = NULL,
verbose = FALSE, plot = FALSE, linetype_var = 'set', ...
){
# Assert
......@@ -264,7 +246,8 @@ extend <- function(
newgr$set <- 'extensions'
allgr <- c(gr, newgr)
allgr$set %<>% factor(c('original', 'extensions'))
print(plot_intervals(allgr, linetype_var = linetype_var, ..., title=txt))
print(plot_intervals(
allgr, linetype_var = linetype_var, ..., title=txt))
newgr$set <- NULL
}
if (verbose) message(txt)
......@@ -392,7 +375,8 @@ double_flank <- function(
newgr$set <- 'flanks'
allgr <- c(gr, newgr)
allgr$set %<>% factor(c('original', 'flanks'))
print(plot_intervals(allgr, linetype_var = linetype_var, title = txt, ...))
print(plot_intervals(
allgr, linetype_var = linetype_var, title = txt, ...))
newgr$set <- NULL
}
......
......@@ -184,30 +184,19 @@ find_pe_spacers <- function(gr, bsgenome, fixes = get_plus_seq(bsgenome, gr),
# Extract from these other components
bs <- bsgenome; invstr <- invertStrand
add_fixed_seqs <- function(gr, bsgenome, fixes){
# Get '+' seq
gr$seq <- get_plus_seq(bsgenome, gr)
substr(gr$seq, gr$targetstart - start(gr)+1,
gr$targetend - start(gr)+1) <- fixes[gr$targetname]
gr$seq[as.logical(strand(gr)=='-')] %<>% revcomp()
gr
}
spacer <- up_flank(gg, -21, -2) %>% add_seq(bs)
pam <- up_flank(gg, -1, +1) %>% add_seq(bs)
primer <- up_flank(gg, -4-nprimer, -5) %>% add_seq(bs)
revtranscript<- up_flank(gg, -4, -5+nrt) %>% add_fixed_seqs(bs, fixes)
ext <- up_flank(gg, -4-nprimer, -5+nrt) %>% invertStrand() %>% add_fixed_seqs(bs, fixes)
# Revcomp for "-" seqs
ext <- up_flank(gg, -4-nprimer, -5+nrt) %>% invertStrand() %>%
add_fixed_seqs(bs, fixes) # Revcomp for "-" seqs
# Plot
if (plot){
spacer$part<-'spacer'
ext$part <- "3' extension"
allranges <- c(spacer, ext)
#allranges$part %<>% factor(rev(c("spacer", "3' extension")))
allranges$part %<>% factor((c("spacer", "3' extension")))
# print(plot_intervals(allranges, y = 'crisprname', linetype_var = 'part',
# size_var = 'part', facet_var = c('seqnames', 'targetname')))
print(plot_intervals(allranges, y = 'crisprname', linetype_var = 'part',
print(plot_intervals(allranges, y = 'crisprname', linetype_var = 'part',
facet_var = c('seqnames', 'targetname')))
spacer$part <- NULL
}
......@@ -221,9 +210,14 @@ find_pe_spacers <- function(gr, bsgenome, fixes = get_plus_seq(bsgenome, gr),
spacer
}
add_fixed_seqs <- function(gr, bsgenome, fixes){
# Get '+' seq
gr$seq <- get_plus_seq(bsgenome, gr)
substr(gr$seq, gr$targetstart - start(gr)+1,
gr$targetend - start(gr)+1) <- fixes[gr$targetname]
gr$seq[as.logical(strand(gr)=='-')] %<>% revcomp()
gr
}
get_plus_seq <- function(bsgenome, gr){
seqs1 <- BSgenome::getSeq(bsgenome,
......
......@@ -141,8 +141,8 @@ find_spacers <- function(
spacers <- extend(sites, 0, -3, bsgenome = bsgenome)
pams <- down_flank(sites, -2, 0, bsgenome = bsgenome)
spacers$crisprname <- names(spacers)
spacers$crisprspacer <- BSgenome::getSeq(bsgenome, spacers, as.character=TRUE)
spacers$crisprpam <- BSgenome::getSeq(bsgenome, pams, as.character=TRUE)
spacers$crisprspacer <- getSeq(bsgenome, spacers, as.character=TRUE)
spacers$crisprpam <- getSeq(bsgenome, pams, as.character=TRUE)
spacers %>% sort(ignore.strand = TRUE)
if (plot){
print(plot_intervals(spacers, y='crisprname'))
......@@ -238,7 +238,8 @@ extend_for_pe <- function(
# # Rm crispr-free targetranges
# idx <- targetdt[, substart == 'NA']
# if (sum(idx)>0){
# if (verbose) cmessage('\t\tRm %d ranges with no crispr site', sum(idx))
# if (verbose) cmessage('\t\tRm %d ranges with no crispr site',
# sum(idx))
# targetdt %<>% extract(!idx)
# }
#
......@@ -246,31 +247,31 @@ extend_for_pe <- function(
# targetdt[, targetstart := start]
# targetdt[, targetend := end ]
#
# sites_dt <- tidyr::separate_rows(targetdt, substart, subend) %>%
# data.table() %>%
# extract(, substart := as.numeric(substart)) %>%
# extract(, subend := as.numeric(subend)) %>%
# extract(, seq := substr(seq, substart, subend)) %>%
# extract( strand=='+', crispr_start := start + substart - 1) %>%
# extract( strand=='+', crispr_end := start + subend - 1) %>%
# extract( strand=='-', crispr_start := end - subend + 1) %>%
# extract( strand=='-', crispr_end := end - substart + 1) %>%
# extract(, list(
# seqnames = seqnames, start = crispr_start,
# end = crispr_end, strand = strand, seq = seq,
# targetname = targetname, targetstart = targetstart,
# targetend = targetend))
# sites_dt <- tidyr::separate_rows(targetdt, substart, subend) %>%
# data.table() %>%
# extract(, substart := as.numeric(substart)) %>%
# extract(, subend := as.numeric(subend)) %>%
# extract(, seq := substr(seq, substart, subend)) %>%
# extract( strand=='+', crispr_start := start + substart - 1) %>%
# extract( strand=='+', crispr_end := start + subend - 1) %>%
# extract( strand=='-', crispr_start := end - subend + 1) %>%
# extract( strand=='-', crispr_end := end - substart + 1) %>%
# extract(,
# list(seqnames = seqnames, start = crispr_start,
# end = crispr_end, strand = strand, seq = seq,
# targetname = targetname, targetstart = targetstart,
# targetend = targetend))
# sites <- GRanges(unique(sites_dt), seqinfo = seqinfo(gr))
# sites$site <- uniquify(sites$targetname)
# spacer <- sites %>% extend( 0, -3, stranded=TRUE, bsgenome = bsgenome)
# pam <- sites %>% down_flank(-2, 0, stranded=TRUE, bsgenome = bsgenome)
# spacer <- sites %>% extend( 0, -3, stranded=TRUE, bsgenome=bsgenome)
# pam <- sites %>% down_flank(-2, 0, stranded=TRUE, bsgenome=bsgenome)
# spacer$spacer <- spacer$seq
# spacer$seq <- NULL
# spacer$pam <- pam$seq
#
# # Plot. Message. Return
# if (plot){
# original <- copy(sites, start=sites$targetstart, end=sites$targetend)
# original <- copy(sites, start=sites$targetstart, end=sites$targetend)
# original$set <- 'target'
# spacer$set <- 'spacer'
# plot_intervals(c(original, spacer), color_var = 'set',
......@@ -284,90 +285,3 @@ extend_for_pe <- function(
# Add three prime extensions
#
# Add three prime extensions for prime editing
#
# A prime editor contains spacer and 3'extensions
# This function adds these extension seqs for the specified spacer(range)s
#
# ====== spacer =====>.........................
# 1--------------17----GG---------> .
# <--------------------CC---------- .
# <====== extension ==========............
# <====pbs=====<===rttemplate==
#
# @param spacers \code{\link[GenomicRanges]{GRanges-class}}: spacers
# @param bsgenome \code{\link[BSgenome]{BSgenome-class}}
# @param fixes character vector: '+' strand fix seqs
# @param nprimer n primer nucleotides (default 13, max 17)
# @param nrt n rev transcr nucleotides (default 16, recomm. 10-16)
# @param spacer string: spacer pattern in extended IUPAC alphabet
# @param pam string: pam pattern in extended IUPAC alphabet
# @param plot TRUE (default) or FALSE
# @return Prime editing spacer \code{\link[GenomicRanges]{GRanges-class}},
# with 3' extension sequences (required for cloning) added.
# @examples
# require(magrittr)
# bsgenome <- BSgenome.Hsapiens.UCSC.hg38::BSgenome.Hsapiens.UCSC.hg38
# gr <- GenomicRanges::GRanges(
# seqnames = c(PRNP = 'chr20:4699600', # snp
# HBB = 'chr11:5227002', # snp
# HEXA = 'chr15:72346580-72346583', # del
# CFTR = 'chr7:117559593-117559595'), # ins
# strand = c(PRNP = '+', HBB = '-', HEXA = '-', CFTR = '+'),
# seqinfo = BSgenome::seqinfo(bsgenome))
#
# spacers <- gr %>% extend_for_pe() %>% find_spacers(bsgenome)
#
# BSgenome::getSeq(bsgenome, gr)
# add_prime_extensions(gr, bsgenome)
# @seealso \code{\link{find_spacers}} to find standard crispr sites
# @export
# add_prime_extensions <- function(
# spacers,
# bsgenome,
# rttemplate = getSeq(bsgenome, down_flank(spacers, -2, -3+nrt), as.character = TRUE),
# nprimer = 13,
# nrt = 16,
# spacer = strrep('N', 20),
# pam = 'NGG',
# plot = TRUE
# ){
#
# # Assert
# assert_is_all_of(spacers, 'GRanges')
# assert_is_all_of(bsgenome, 'BSgenome')
# assert_is_character(fixes)
# assert_all_are_matching_regex(fixes, '^[ACGTacgt]+$')
# assert_is_a_number(nprimer)
# assert_is_a_number(nrt)
# assert_all_are_less_than(nprimer, 17)
# .
# # Extensions
# extension <- invertStrand(down_flank(spacers, -2-nprimer, -3+nrt))
# extension$seq <- get_plus_seq(bsgenome, extension) # Get "+" seq
# substr( extension$seq,
# extension$tstart-start(extension)+1,
# extension$tend -start(extension)+1) <- fixes[extension$tname]
# extension$seq[as.logical(strand(extension)=='-')] %<>% revcomp() # Revcomp for "-" seqs
#
# # Plot
# if (plot){
# spacer$part<-'spacer'; primer$part<-'primer'; rtranscripts$part<-'rtranscripts'
# allranges <- c(spacer, primer, rtranscripts)
# allranges$part %<>% factor(rev(c('spacer', 'rtranscripts', 'primer')))
# plot_intervals(allranges, y = 'site', color_var = 'part',
# size_var = 'part', facet_var = c('seqnames', 'targetname'))
# spacer$part <- primer$part <- rtranscripts$part <- NULL
# }
#
# # Add sequences and return
# names(mcols(spacer)) %<>% stri_replace_first_fixed('seq', 'spacer')
# spacer$pam <- pam$seq
# spacer$extension <- extension$seq
# spacer
# }
......@@ -176,6 +176,7 @@ read_bowtie_results <- function(outfile){
#' @param mismatches max number of mismatches to consider
#' @param outdir string: multicrispr output directory
#' @param verbose TRUE (default) or FALSE
#' @return data.table
#' @seealso \code{\link{index_genome}}, \code{\link{index_targets}}
#' @examples
#' # TFBS example
......@@ -251,6 +252,7 @@ expand_iupac_ambiguities <- function(x){
#' @param outdir string: file where to output bowtie results
#' @param pam string (default 'NGG') pam pattern to expand
#' @param verbose TRUE (default) or FALSE