This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(BiocParallel) | |
| library(DelayedArray) | |
| #' @importFrom stats start end | |
| .grid_iterate <- function(x, grid = NULL) { | |
| b <- 0L | |
| function() { | |
| if (b == length(grid)) { | |
| return(NULL) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "beachtest.h" | |
| // Don't forget to set appropriate PKG_CXXFLAGS. | |
| #include <omp.h> | |
| #include <iostream> | |
| extern "C"{ | |
| SEXP parallel_reader(SEXP input) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(edgeR) | |
| g <- factor(rep(1:4, c(50, 20, 10, 5))) | |
| N <- 20000 | |
| mus <- 100 | |
| # mus <- 100 * 2^rnorm(N*length(g)) # Uncomment for variable mu | |
| y <- matrix(rnbinom(N*length(g), mu=mus, size=1), nrow=N, byrow=TRUE) | |
| design <- model.matrix(~gl(2,2)) | |
| # Summation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(scRNAseq) | |
| hESCs <- LaMannoBrainData('human-es') | |
| # Trivial function to get something working on two matrices. | |
| FUN <- function(x, y) { list(colSums(x), colSums(y)) } | |
| library(BiocParallel) | |
| BPPARAM1 <- SerialParam() | |
| BPPARAM5 <- MulticoreParam(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############# The usual ################ | |
| library(scRNAseq) | |
| # Example data ---- | |
| sce <- ReprocessedAllenData(assays="tophat_counts") | |
| class(sce) | |
| library(scater) | |
| sce <- logNormCounts(sce, exprs_values="tophat_counts") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tiledb) | |
| dim <- c(500L, 200L) | |
| context <- tiledb_ctx() | |
| collected <- vector("list", length(dim)) | |
| for (i in seq_along(dim)) { | |
| collected[[i]] <- tiledb_dim(ctx=context, paste0("d", i), c(1L, dim[i]), tile=100L, type="INT32") | |
| } | |
| dom <- tiledb_domain(ctx=context, dims=collected) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The hue is evenly distributed along the circle; | |
| # we oscillate the luminescence to provide a better | |
| # distinction between similar colors. | |
| n <- 30 | |
| i <- head(seq(0, 360, length.out=n+1), -1) | |
| cols <- hcl(i, c=50, l=80 + 10 * sin(i/30 * pi)) | |
| plot(seq_along(cols), col=cols, pch=16, cex=5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mat <- matrix(rnorm(100000), ncol=10) | |
| library(BiocNeighbors) | |
| res <- findKNN(mat, k=20) | |
| d <- res$distance[,ncol(res$distance)] | |
| processed <- logical(nrow(mat)) | |
| candidates <- logical(nrow(mat)) | |
| while (!all(processed)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function range(x) { | |
| let maxed = Number.NEGATIVE_INFINITY; | |
| let mined = Number.POSITIVE_INFINITY; | |
| for(const y of x) { | |
| if (y > maxed) { | |
| maxed = y; | |
| } | |
| if (y < mined) { | |
| mined = y; | |
| } |
OlderNewer