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) | |
X = dplyr::filter(datasaurus_dozen,dataset=="dino") %>% | |
dplyr::select(-dataset) %>% | |
as.matrix() | |
res_svd <- svd(as.matrix(X)) | |
df_svd <- bind_rows(data.frame(res_svd$u, matrix="U"), |
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(ti, period=16) { | |
coeff <- 2*pi/period | |
matrix(c(cos(coeff*ti),-sin(coeff*ti), | |
sin(coeff*ti), cos(coeff*ti)), 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
#include "RcppArmadillo.h" | |
// [[Rcpp::depends(RcppArmadillo)]] | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace Rcpp; | |
void readmtx(arma::uvec & row_i, | |
arma::uvec & col_i, |
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)]] | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
std::vector<double> readaline(std::string readtxt, int ind_n) { | |
std::ifstream file(readtxt); |
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)))+ |