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
query_awk <- function(vpar, pdir, filename, uid){ | |
chl <- paste0("cat ", pdir, "/", filename) | |
for(i in 1:nrow(vpar)){ | |
chr <- paste0("\"", paste(vpar[i,], collapse = ", "), "\"") | |
awk <- paste0(" | awk 'NR==", uid[i], "{sub('/.*/',", chr, ")}1'") | |
chl <- paste0(chl, awk) | |
} | |
chl <- paste0(chl, " > ", pdir, "/tmp.csv") | |
mvit <- paste0("mv ", pdir, "/tmp.csv " , pdir, "/", filename) | |
system(chl) |
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
x = seq(-4,4,length.out=100) | |
y = seq(-4,4,length.out=100) | |
df <- expand.grid(x = x, y = y) | |
prob <- matrix(pnorm(df$x)*pnorm(df$y), 100, 100) | |
#png("persp.png") | |
persp(x = x, y = y, z = prob, theta = 20, phi=45) | |
#dev.off() | |
#png("contour.png") |
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(datasauRus) | |
library(ggplot2) | |
library(dplyr) | |
library(gganimate) | |
rot <-function(th) { | |
matrix(c(cos(th),-sin(th), | |
sin(th),cos(th)), byrow = TRUE, nrow = 2) | |
} |
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
n <- 1000 | |
rate <- 1 | |
set.seed(1234) | |
tau_x <- rgamma(n,1,1) | |
X <- rpois(n,tau_x*rate) | |
tau_y <- rgamma(n,2,1) | |
Y <- rpois(n,tau_y*rate) | |
#png("ECDF_rate.png") | |
curve(ecdf(X/tau_x)(x), type = "s", xlim = c(0, 15), ylim=c(0,1), col="royalblue", ylab = "ECDF", xlab = "ratio") | |
curve(ecdf(Y/tau_y)(x), type = "s", add=TRUE, col="orangered", lty=2) |
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(Matrix) | |
library(readr) | |
library(tidyr) | |
library(dplyr) | |
library(ggplot2) | |
library(umap) | |
library(patchwork) | |
#https://www.weizmann.ac.il/sites/3CA/breast | |
cells <- read_csv("./data/Data_Chung2017_Breast/Cells.csv") |
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(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
df1 <- mutate(iris, id=1:n()) %>% | |
pivot_longer(1:4) | |
ggplot(df1,aes(x=name,y=value,group=id, colour = Species))+ | |
geom_line(alpha=0.5)+ | |
guides(colour=guide_legend(override.aes = list(alpha=1, linewidth=1)))+ |
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(dplyr) | |
library(MASS) | |
data("diamonds", package = "ggplot2") | |
diamonds2 <- dplyr::select(diamonds, carat, depth:price,x:z) | |
a01 <- rgb(0,0,0,0.1) | |
png("pairs.png") | |
plot(diamonds2, col=a01) | |
dev.off() |
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(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(patchwork) | |
df1 <- mutate(iris,id=1:n()) %>% | |
pivot_longer(1:4) | |
df2 <-reframe(df1, x=c(as.integer(factor(name))-0.25,as.integer(factor(name))+0.25), |
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
scan1_mtx <- function(con, skip = 0){ | |
base::scan(con, nmax = 1, quiet=TRUE, | |
what = list(i=integer(), j=integer(), v=numeric()), | |
skip = skip) | |
} | |
dataloader_mtx2 <- function(file_path, bag){ | |
con <- file(file_path, open = "r") #Open for reading in text mode | |
#get matrix size |
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 "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
using namespace Rcpp; | |
using namespace arma; | |
// [[Rcpp::export]] | |
double sumouterprod(const arma::field<arma::vec> & V){ | |
int K = V.n_rows; | |
arma::vec tout = V(0); | |
for(int j=1; j<K; j++){ |