Commit ba714869 authored by aditya.bhagwat's avatar aditya.bhagwat
Browse files

BiocCheck

parent 672ba7c7
Pipeline #130120 passed with stages
in 24 seconds
......@@ -366,7 +366,7 @@ double_flank <- function(
names(dn) %<>% paste0('_d')
newgr <- c(up, dn)
txt <- sprintf('\t\t%d flank ranges: %d up + %d down',
length(newgr), length(up), length(dn))
length(newgr), length(up), length(dn))
message(txt)
# Plot
......
......@@ -197,7 +197,7 @@ find_pe_spacers <- function(gr, bsgenome, fixes = get_plus_seq(bsgenome, gr),
allranges <- c(spacer, ext)
allranges$part %<>% factor((c("spacer", "3' extension")))
print(plot_intervals(allranges, y = 'crisprname', linetype_var = 'part',
facet_var = c('seqnames', 'targetname')))
facet_var = c('seqnames', 'targetname')))
spacer$part <- NULL
}
......@@ -208,7 +208,7 @@ find_pe_spacers <- function(gr, bsgenome, fixes = get_plus_seq(bsgenome, gr),
spacer$revtranscript <- revtranscript$seq
spacer$extension <- ext$seq
spacer
}
}
add_fixed_seqs <- function(gr, bsgenome, fixes){
# Get '+' seq
......
......@@ -99,7 +99,7 @@
#' extract_subranges(gr, ir, plot = TRUE)
#' @export
extract_subranges <- function(gr, ir, plot = FALSE){
# Comply / Assert
substart <- subwidth <- NULL
assert_is_all_of(gr, 'GRanges')
......@@ -113,8 +113,8 @@ extract_subranges <- function(gr, ir, plot = FALSE){
idt <- data.table::as.data.table(ir)
gdt <- data.table::as.data.table(gr) %>% cbind(names = names(gr))
gdt$width <- NULL
setnames(idt, c( 'start', 'end', 'width'),
c('substart', 'subend', 'subwidth'))
setnames(idt, c( 'start', 'end', 'width'),
c('substart', 'subend', 'subwidth'))
mdt <- merge(gdt, idt, by = 'names')
# Extract
......@@ -164,7 +164,7 @@ extract_subranges <- function(gr, ir, plot = FALSE){
#' extract_matchranges(gr, bsgenome, pattern = strrep('N',20) %>% paste0('NGG'))
#' @export
extract_matchranges <- function(gr, bsgenome, pattern, plot = FALSE){
# Assert
assert_is_all_of(gr, 'GRanges')
assert_has_names(gr)
......@@ -272,10 +272,10 @@ extend_for_pe <- function(
names(rv) %<>% paste0('_r')
ext <- c(fw, rv)
if (plot){
gr$set <- 'PE target'
fw$set <- "potential '+' spacers"
rv$set <- "potential '-' spacers"
print(plot_intervals(c(fw, gr, rv), color_var = 'set', y = 'set'))
gr$set <- 'PE target'
fw$set <- "potential '+' spacers"
rv$set <- "potential '-' spacers"
print(plot_intervals(c(fw, gr, rv), color_var = 'set', y = 'set'))
}
ext
}
......
......@@ -45,7 +45,7 @@ index_genome <- function(
if (!overwrite &
dir.exists(genomedir) & length(list.files(genomedir))!=0){
cmessage('%s already contains index - set overwrite=TRUE to overwrite',
genomedir)
genomedir)
return(invisible(genomedir))
}
......@@ -148,8 +148,8 @@ read_bowtie_results <- function(outfile){
dt <- data.table::fread(
outfile,
col.names = c('readname', 'strand', 'target', 'position',
'readseq', 'quality', 'matches', 'mismatches'))
col.names = c( 'readname', 'strand', 'target', 'position',
'readseq', 'quality', 'matches', 'mismatches'))
dt[ is.na(mismatches), mismatch := 0]
dt[!is.na(mismatches), mismatch := stringi::stri_count_fixed(
mismatches, '>')]
......@@ -280,7 +280,7 @@ match_spacers <- function(
crisprdt <- data.table(
crisprspacer = rep(spacerseqs, each=length(pamseqs)),
crisprpam = rep(pamseqs, times=length(spacerseqs))) %>%
extract(, crispr := paste0(crisprspacer, pamseqs))
extract(, crispr := paste0(crisprspacer, pamseqs))
crisprseqs <- unique(crisprdt$crispr)
# Count matches
......@@ -297,7 +297,7 @@ match_spacers <- function(
spacer_dt <- data.table(crisprspacer = unique(matches$crisprspacer))
for (var in count_vars){
spacer_dt %<>% merge(matches[ , list(counts = sum(get(var))),
by = 'crisprspacer'],
by = 'crisprspacer'],
by = 'crisprspacer')
setnames(spacer_dt, 'counts', var)
}
......@@ -470,8 +470,8 @@ add_specificity <- function(
spacers$specific <- FALSE
idx <- rep(TRUE, length(spacers))
for (mis in 0:2){
idx %<>% and(mcols(spacers)[[paste0('T', mis)]] ==
mcols(spacers)[[paste0('G', mis)]])
idx %<>% and( mcols(spacers)[[paste0('T', mis)]] ==
mcols(spacers)[[paste0('G', mis)]])
if (verbose) cmessage('\t %s T%d==G%d',
format(sum(idx), width = digits), mis, mis)
}
......
......@@ -99,9 +99,9 @@ doench2016 <- function(
cmessage(txt, length(contextchunks), chunksize)
mc.cores <- if (is_windows()) 1 else parallel::detectCores()-2
doench2016scores <- unlist(parallel::mclapply(contextchunks,
function(x){
reticulate::py_suppress_warnings(
azi$predict( reticulate::np_array(x),
function(x){
reticulate::py_suppress_warnings(
azi$predict( reticulate::np_array(x),
aa_cut = NULL,
percent_peptide = NULL,
model = NULL,
......@@ -109,12 +109,12 @@ doench2016 <- function(
pam_audit = TRUE,
length_audit = TRUE,
learn_options_override = NULL))},
mc.cores = mc.cores))
mc.cores = mc.cores))
# Return
end_time <- Sys.time()
if (verbose) cmessage('\t\tCompleted in %s',
format(end_time - start_time, digits = 2))
format(end_time - start_time, digits = 2))
doench2016scores
}
......@@ -220,7 +220,7 @@ add_efficiency <- function(
# Merge back in
mergedt <- merge(spacerdt, scoredt,
by='crisprcontext', sort=FALSE, all.x=TRUE)
by='crisprcontext', sort=FALSE, all.x=TRUE)
spacers <- dt2gr(mergedt, seqinfo = seqinfo(spacers))
# Plot
......@@ -261,7 +261,7 @@ filter_efficient <- function(
width <- nchar(length(idx))
cmessage('\t\t%s ranges', formatC(length(idx), width = width))
cmessage('\t\t%s ranges after filtering for %s > %s',
formatC(sum(idx), width = width), method, as.character(cutoff))
formatC(sum(idx), width = width), method, as.character(cutoff))
}
spacers %>% extract(idx)
......
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