From bdb0f7e6e374c4f6162d51916af54e015692939f Mon Sep 17 00:00:00 2001 From: Luke Hoberecht Date: Wed, 14 Sep 2022 15:07:54 -0700 Subject: [PATCH] Fixed issue with longer introns; added ability to plot multiple genes --- DESCRIPTION | 2 +- R/plotGuideSet.R | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 04c068d..968ee16 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: crisprViz Title: Visualization Functions for CRISPR gRNAs -Version: 0.99.21 +Version: 0.99.22 Authors@R: c( person("Jean-Philippe", "Fortin", email = "fortin946@gmail.com", role = c("aut", "cre")), person("Luke", "Hoberecht", email = "lukehob3@gmail.com", role = c("aut")) diff --git a/R/plotGuideSet.R b/R/plotGuideSet.R index 772772e..3d54940 100644 --- a/R/plotGuideSet.R +++ b/R/plotGuideSet.R @@ -140,10 +140,12 @@ plotGuideSet <- function(x, to <- plotWindowMax + margin * plotWindowSize } ## have geneTrack adjust to plot window - geneTrack <- .getGeneTrack(geneModel=geneModel, - targetGene=targetGene, - from=from - extend.left, - to=to + extend.right) + geneTrack <- lapply(targetGene, function(x){ + .getGeneTrack(geneModel=geneModel, + targetGene=x, + from=from - extend.left, + to=to + extend.right) + }) annotationTrack <- .getAnnotationTrack(annotations=annotations, chr=chr, @@ -300,7 +302,7 @@ plotGuideSet <- function(x, ## for tx_id above that exceed limit, append "exon" beyond limit exonLeft <- lapply(txLeft, function(x){ - strand <- unique(BiocGenerics::strand(splicings)) + strand <- unique(BiocGenerics::strand(transcripts)) currentRanks <- splicings$exon_rank[splicings$tx_id == x] if (length(currentRanks) == 0){ exon_rank <- ifelse(strand == "+", 1, 2) @@ -310,11 +312,11 @@ plotGuideSet <- function(x, exon_rank <- max(currentRanks) + 1 } GenomicRanges::GRanges( - seqnames=unique(GenomeInfoDb::seqnames(splicings)), + seqnames=unique(GenomeInfoDb::seqnames(transcripts)), ranges=IRanges::IRanges(start=from-extendDistance, width=1), strand=strand, tx_id=x, - gene_id=unique(splicings$gene_id), + gene_id=unique(transcripts$gene_id), protein_id=NA, tx_type=NA, gene_symbol=NA, @@ -331,7 +333,7 @@ plotGuideSet <- function(x, exonLeft <- Reduce(c, exonLeft) exonRight <- lapply(txRight, function(x){ - strand <- unique(BiocGenerics::strand(splicings)) + strand <- unique(BiocGenerics::strand(transcripts)) currentRanks <- splicings$exon_rank[splicings$tx_id == x] if (length(currentRanks) == 0){ exon_rank <- ifelse(strand == "+", 2, 1) @@ -341,11 +343,11 @@ plotGuideSet <- function(x, exon_rank <- min(currentRanks) - 1 } GenomicRanges::GRanges( - seqnames=unique(GenomeInfoDb::seqnames(splicings)), + seqnames=unique(GenomeInfoDb::seqnames(transcripts)), ranges=IRanges::IRanges(start=to+extendDistance, width=1), strand=strand, tx_id=x, - gene_id=unique(splicings$gene_id), + gene_id=unique(transcripts$gene_id), protein_id=NA, tx_type=NA, gene_symbol=NA,