Skip to content
Snippets Groups Projects
Commit 97fa3400 authored by Arnaud Duvermy's avatar Arnaud Duvermy
Browse files

Delete test.R

parent a1d1375b
No related branches found
No related tags found
No related merge requests found
## distribution reads per gene pour 1 mutant
y <- rnbinom(n = 6000, mu = 50, size = 5)
table(y)
barplot(table(y))
treatment <- sample(c(0,1), size = 2000, replace = TRUE)
treatment
c(0,1)
#range_mu = runif(1000, min=50, max=55)
#range_size = runif(1000, min=5, max=6)
#sample(range_mu, size = 1000, replace = TRUE)
N_gene = 6000
N_mutant = 1 # for now
N_environment = 2
y_env1 = rnbinom(n = N_gene, mu = 50, size = 5)
y_env2 = rnbinom(n = N_gene, mu = 2, size = 5) # modif distrib per environment
y = c(y_env1, y_env2)
mydta = array(data = y , dim = c(N_gene,N_mutant,N_environment))
mydta[,,1]
dimnames(mydta) <- list("N" = sprintf("gene%d", 1:N_gene),
"M" = sprintf("mutant%d", 1:N_mutant),
"K" = sprintf("environment%d", 1:N_environment))
mydta[,,]
lol <- list(structure(list(pair = c("BoneMarrow", "Pulmonary"), genes = "PRR11"),
.Names = c("pair", "genes")),
structure(list(pair = c("BoneMarrow", "Umbilical"), genes = "GNB2L1"),
.Names = c("pair", "genes")),
structure(list(pair = c("Pulmonary", "Umbilical"), genes = "ATP1B1"), .Names = c("pair","genes")))
lol[[1]]$pair
library(tidyverse)
map_dfr(lol, ~as_tibble(.) %>%
mutate(row=paste0("pair", row_number()))%>%
spread(row, pair) %>%
select(pair1, pair2, genes))
#replicate(n=10,rnbinom(n = 1, mu = 50, size = 5))
##test
set.seed(1982)
N <- 6000
M <- 1000
K <- 2
example_3d_array <- array(rnbinom(n = 1, mu = 50, size = 5), c(M, K))
example_3d_array[,,2][3,]
library("dplyr")
#system.time(expr = {
dimnames(example_3d_array) <- list("N" = sprintf("N%d", 1:N),
"M" = sprintf("M%d", 1:M),
"K" = sprintf("K%d", 1:K))
example_3d_cube <- as.tbl_cube(example_3d_array)
example_2d_df <- as_tibble(example_3d_cube)
#}
#)
#params
N_gene = 6000
## function generator
rnbinom_generator <- function(n_gene, mu_simul, alpha){
my_counts <- rnbinom(n = n_gene, mu = mu_simul, size = alpha)
return(my_counts)
}
## build my lib counts
env1_A <- rnbinom_generator(N_gene, 50, 5)
env1_B <- rnbinom_generator(N_gene, 50, 5)
env2_A <- rnbinom_generator(N_gene, 100, 5)
env2_B <- rnbinom_generator(N_gene, 100, 5)
## export my lib count
names(env1_A) <- sprintf("gene%d", 1:N_gene)
names(env1_B) <- sprintf("gene%d", 1:N_gene)
names(env2_A) <- sprintf("gene%d", 1:N_gene)
names(env2_B) <- sprintf("gene%d", 1:N_gene)
env1_A %>% data.frame(.) %>% fwrite(., "~/mydatalocal/counts_simulation/results/env1_A.tsv", row.names = T, col.names = F, sep = "\t")
env2_A %>% data.frame(.) %>% fwrite(., "~/mydatalocal/counts_simulation/results/env2_A.tsv", row.names = T, col.names = F, sep = "\t")
env1_B %>% data.frame(.) %>% fwrite(., "~/mydatalocal/counts_simulation/results/env1_B.tsv", row.names = T, col.names = F, sep = "\t")
env2_B %>% data.frame(.) %>% fwrite(., "~/mydatalocal/counts_simulation/results/env2_B.tsv", row.names = T, col.names = F, sep = "\t")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment