Skip to content

Commit

Permalink
Added consensus exons option for exonTable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jfortin1 committed Oct 15, 2022
1 parent a0d6db0 commit 8dcbfd1
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: crisprDesign
Title: Comprehensive design of CRISPR gRNAs for nucleases and base editors
Version: 0.99.176
Version: 0.99.177
Authors@R: c(
person("Jean-Philippe", "Fortin", email = "[email protected]", role = c("aut", "cre")),
person("Luke", "Hoberecht", email = "[email protected]", role = c("aut"))
Expand Down
61 changes: 59 additions & 2 deletions R/addExonTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
#' @param valueColumn String specifying column in
#' \code{geneAnnotation(guideSet)} to use as values in the
#' output exon table.
#' @param useConsensusIsoform Should a consensus isoform be used to
#' annotate exons? FALSE by default. If TRUE, the isoform constructed
#' by \code{getConsensusIsoform} will be used.
#'
#' @return A \linkS4class{GuideSet} object with a "exinTable" DataFrame
#' @return A \linkS4class{GuideSet} object with a "exonTable" DataFrame
#' stored in \code{mcols(guideSet)}. The entries in the DataFrame
#' correspond to the values specified by \code{valueColumn}.
#' Rows correspond to gRNAs in the GuideSet, columns correspond to
Expand Down Expand Up @@ -43,7 +46,57 @@
addExonTable <- function(guideSet,
gene_id,
txObject,
valueColumn="percentCDS"
valueColumn="percentCDS",
useConsensusIsoform=FALSE
){
if (useConsensusIsoform){
gs <- addExonTable_consensusIsoform(guideSet=guideSet,
gene_id=gene_id,
txObject=txObject)
} else {
gs <- addExonTable_allIsoforms(guideSet=guideSet,
gene_id=gene_id,
txObject=txObject,
valueColumn=valueColumn)
}
return(gs)
}



addExonTable_consensusIsoform <- function(guideSet,
gene_id,
txObject
){
consensus <- getConsensusIsoform(gene_id=gene_id,
txObject=txObject)
exonids <- unique(consensus$exon_id)
guides <- names(guideSet)
out <- matrix(NA,
nrow=length(guides),
ncol=length(exonids))
rownames(out) <- guides
colnames(out) <- exonids
out <- as.data.frame(out)

# Looking at overlap:
gr <- getCutSiteRanges(guideSet,
nuclease=crisprNuclease(guideSet))
df <- findOverlaps(gr, consensus, ignore.strand=TRUE)
df <- as.data.frame(df)
for (k in seq_len(nrow(df))){
out[df[k,1],df[k,2]] <- 1
}
out <- DataFrame(out)
mcols(guideSet)$exonTable <- out
return(guideSet)
}


addExonTable_allIsoforms <- function(guideSet,
gene_id,
txObject,
valueColumn="percentCDS"
){
stopifnot(.hasGeneAnnotation(guideSet))

Expand Down Expand Up @@ -76,3 +129,7 @@ addExonTable <- function(guideSet,
return(guideSet)
}





14 changes: 12 additions & 2 deletions man/addExonTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8dcbfd1

Please sign in to comment.