This file contains 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
# Demonstrate that this is chi-squared distributed | |
# with xyz - (x-1) - (y-1) - (z-1) -1 d.f. | |
stat <- numeric(1000) | |
for (i in seq_along(stat)) { | |
N <- 1000 | |
x <- rmultinom(1, size=N, prob=rep(1/27, 27)) | |
dim(x) <- c(3,3,3) | |
p1 <- vapply(1:3, function(i) sum(x[i,,]), 1) / N | |
p2 <- vapply(1:3, function(i) sum(x[,i,]), 1) / N |
This file contains 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; | |
} |
This file contains 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 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 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 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 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 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 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 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) | |
} |
NewerOlder