crisprVerse / Tutorials

Tutorials for the crisprVerse
MIT License
10 stars 0 forks source link

Error in .checkCutSitesOrder(GuideSet1, GuideSet2) #5

Closed liu-zhiyang closed 7 months ago

liu-zhiyang commented 9 months ago

Hi, I am trying to use crisprVerse for paired gRNA design. But when I ran the findSpacerPairsfunction, it returned an error.

> data(SpCas9, package = "crisprBase")
> bsgenome <- BSgenome.Hsapiens.UCSC.hg38
> pairs <- findSpacerPairs(
+   x1 = upstream,
+   x2 = downstream,
+   bsgenome = bsgenome,
+   crisprNuclease = SpCas9
+ )
Error in .checkCutSitesOrder(GuideSet1, GuideSet2) : 
  Some of the pairs are not ordered properly. The cut site
              of gRNA1 must be upstream of the cut site of gRNA2.

And here is my input.

> upstream
GRanges object with 245 ranges and 0 metadata columns:
        seqnames            ranges strand
           <Rle>         <IRanges>  <Rle>
    [1]     chr1   7961417-7961516      *
    [2]     chr1   9239647-9239746      *
    [3]     chr1 11797330-11797429      *
    [4]     chr1 16364194-16364293      *
    [5]     chr1 19390034-19390133      *
    ...      ...               ...    ...
  [241]    chr22 21847516-21847615      *
  [242]    chr22 37735214-37735313      *
  [243]    chr22 37748491-37748590      *
  [244]    chr22 42960242-42960341      *
  [245]    chr22 50001709-50001808      *
  -------
  seqinfo: 21 sequences from an unspecified genome; no seqlengths
> downstream
GRanges object with 245 ranges and 0 metadata columns:
        seqnames            ranges strand
           <Rle>         <IRanges>  <Rle>
    [1]     chr1   7961908-7962007      *
    [2]     chr1   9240088-9240187      *
    [3]     chr1 11797591-11797690      *
    [4]     chr1 16364605-16364704      *
    [5]     chr1 19390375-19390474      *
    ...      ...               ...    ...
  [241]    chr22 21848257-21848356      *
  [242]    chr22 37735445-37735544      *
  [243]    chr22 37749022-37749121      *
  [244]    chr22 42960503-42960602      *
  [245]    chr22 50001930-50002029      *
  -------
  seqinfo: 21 sequences from an unspecified genome; no seqlengths

Do you have any suggestion about this error? Thank you very much!

Jfortin1 commented 8 months ago

Hi @liu-zhiyang,

Could you provide the two GRanges object files here (upstream and downstream) to help me debug?

liu-zhiyang commented 7 months ago

Hi @liu-zhiyang,

Could you provide the two GRanges object files here (upstream and downstream) to help me debug?

Apologize for delayed response! Here are the two GRanges, thanks for your reply! downstream.csv upstream.csv

Jfortin1 commented 7 months ago

Hi @liu-zhiyang, thanks for the files, that was helpful.

The problem comes from the fact that the function was designed to find all paired guides between all combinations of genomic coordinates between x1 and x2; to find all paired guides in a row-wise manner between x1 and x2, you can use the following code:

ks <- seq_along(upstream)
pairs <- lapply(ks, function(k){
    findSpacerPairs(x1=upstream[k],
                    x2=downstream[k],
                    bsgenome=bsgenome,
                    crisprNuclease=SpCas9)
})
pairs <- do.call("c", pairs)