Commit 6ca989e1 authored by Aditya Bhagwat's avatar Aditya Bhagwat
Browse files

Code filter_N slightly differently

parent 2291d5dc
Package: multicrispr
Title: Multi-locus multi-purpose Crispr/Cas design
Version: 1.5.0
Version: 1.5.1
Encoding: UTF-8
Authors@R: c(person("Aditya", "Bhagwat", NULL, "aditya.bhagwat@mpi-bn.mpg.de", c("aut", "cre")),
person( "Johannes", "Graumann", NULL, 'johannes.graumann@mpi-bn.mpg.de',c("sad", "ctb")),
......@@ -16,7 +16,7 @@ Description: This package is for designing Crispr/Cas9 and Prime Editing experim
enabling the design of large Crispr/Cas9 libraries.
License: GPL-2
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Depends:
R (>= 4.0)
Imports:
......
......@@ -120,6 +120,7 @@ importFrom(methods,as)
importFrom(methods,is)
importFrom(reticulate,py_module_available)
importFrom(stats,complete.cases)
importFrom(stringi,stri_detect_fixed)
importFrom(stringi,stri_detect_regex)
importFrom(stringi,stri_locate_all_fixed)
importFrom(stringi,stri_locate_all_regex)
......
......@@ -43,8 +43,8 @@
#' @importFrom utils tail read.csv read.table
#' @importFrom reticulate py_module_available
#' @importFrom stats complete.cases
#' @importFrom stringi stri_detect_regex stri_locate_all_fixed
#' @importFrom stringi stri_locate_all_regex
#' @importFrom stringi stri_detect_fixed stri_detect_regex
#' @importFrom stringi stri_locate_all_fixed stri_locate_all_regex
#' @importFrom stringi stri_replace_first_fixed
#' @importFrom stringi stri_startswith_fixed
#' @importFrom tidyselect starts_with
......
......@@ -398,12 +398,4 @@ double_flank <- function(
newgr
}
#' Filter N
#'
#' @param spacers \code{\link[GenomicRanges]{GRanges-class}}
#' @return \code{\link[GenomicRanges]{GRanges-class}}
filter_N <- function(spacers, col="crisprspacer"){
spacers <- spacers[!grepl("N",elementMetadata(spacers)[,col])]
spacers[!grepl("N",elementMetadata(spacers)[,"crisprpam"])]
}
......@@ -257,8 +257,10 @@ find_spacers <- function(gr, bsgenome, spacer = strrep('N', 20), pam = 'NGG',
spacers$crisprname <- names(spacers)
spacers$crisprspacer <- getSeq(bsgenome, spacers, as.character=TRUE)
spacers$crisprpam <- getSeq(bsgenome, pams, as.character=TRUE)
# Filter
spacers %<>% extract(!stri_detect_fixed(.$crisprspacer, 'N'))
spacers %<>% extract(!stri_detect_fixed(.$crisprpam, 'N'))
if (verbose) message('\tFound ', length(spacers), ' spacers')
spacers %<>% filter_N()
# Add on/offtargets
spacers %<>% count_offtargets(
bsgenome, targets = if (subtract_targets) gr else NULL,
......@@ -273,6 +275,7 @@ find_spacers <- function(gr, bsgenome, spacer = strrep('N', 20), pam = 'NGG',
spacers
}
#' Extend ranges for prime editing
#'
#' Extend target ranges to span in which to look for spacer-pam seqs
......
......@@ -206,8 +206,8 @@ score_ontargets <- function(
# Add contextseq
if (verbose) cmessage('\tScore ontargets')
spacers %<>% add_context(bsgenome, verbose = verbose)
spacers %<>% filter_N(col="crisprcontext")
spacerdt <- gr2dt(spacers)
spacers %<>% extract(!stri_detect_fixed(.$crisprcontext, 'N'))
spacerdt <- gr2dt(spacers) # context includes spacer + pam already
scoredt <- data.table(crisprcontext = unique(spacerdt$crisprcontext))
# Score
......@@ -233,4 +233,4 @@ score_ontargets <- function(
default_alpha_var <- function(gr){
if ('off' %in% names(mcols(gr))) 'off' else NULL
}
\ No newline at end of file
}
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