Skip to content

Instantly share code, notes, and snippets.

View LTLA's full-sized avatar
🤯
Breaking hearts and minds

Aaron Lun LTLA

🤯
Breaking hearts and minds
View GitHub Profile
@LTLA
LTLA / parallel_crossprod.R
Last active September 22, 2018 17:01
Parallelized calculation of the cross-product, computed with as much memory efficiency as possible.
library(BiocParallel)
library(DelayedArray)
#' @importFrom stats start end
.grid_iterate <- function(x, grid = NULL) {
b <- 0L
function() {
if (b == length(grid)) {
return(NULL)
}
@LTLA
LTLA / intron_exon_counter.R
Last active November 17, 2022 17:49
A script to count reads in introns and exons
# Reading in the annotation.
library(TxDb.Mmusculus.UCSC.mm10.ensGene)
intronic <- intronicParts(TxDb.Mmusculus.UCSC.mm10.ensGene, linked.to.single.gene.only=TRUE)
exonic <- exonicParts(TxDb.Mmusculus.UCSC.mm10.ensGene, linked.to.single.gene.only=TRUE)
IX <- data.frame(GeneID=intronic$gene_id, Chr=as.character(seqnames(intronic)),
Start=start(intronic), End=end(intronic), Strand=strand(intronic), stringsAsFactors=FALSE)
EX <- data.frame(GeneID=exonic$gene_id, Chr=as.character(seqnames(exonic)),
Start=start(exonic), End=end(exonic), Strand=strand(exonic), stringsAsFactors=FALSE)