Skip to content

Instantly share code, notes, and snippets.

params.index = 'testfile2.txt'
Channel
.fromPath(params.index)
.splitCsv(header:true, sep:"\t")
.map{ row-> tuple(row.head1, row.head2, row.head4) }
.into { samples_ch }
process transform {
input:
head1 head2 head3 head4
line.00 afsd col3 another-00
line.01 afsd col3 another-01
line.02 afsd col3 another-02
line.03 afsd col3 another-03
leene.04 afsd col3 another-04
line.05 afsd col3 another-05
leene.06 afsd col3 another-06
loone.07 afsd col3 another-07
loone.08 afsd col3 another-08
@k-hench
k-hench / vcf_sim.R
Created October 8, 2018 15:07
small R script to create a random vcf file for testing purposes
library(tidyverse)
# allele section -----------------
# available base pairs
BS <- c('A','T','C','G')
# sample random base pair
bs <- function(n,replace = TRUE,...) sample(x = BS, size = n, replace = replace, ...)
# sample a possible alternative allele for a single given base pair
alt_bs_1 <- function(bs){
stopifnot(length(bs)==1)
@k-hench
k-hench / rotate_ggplot.R
Created October 31, 2018 07:59
rotating a ggplot obect
library(tidyverse)
library(grid)
raw <- tibble(x = letters[1:5], y = x)
filter <- function(x, y) x <= y
data_tri <- purrr::cross_df(raw,.filter = filter) %>% mutate(val = rnorm(length(.$x)))
plot_tri <- ggplot(data = data_tri, aes(x = x, y = y, fill = val)) +
coord_equal()+
geom_tile() +
@k-hench
k-hench / north.svg
Created November 5, 2018 10:39
svg compass
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
library(tidyverse)
export_2_latex <- function(table, name){
table %>%
mutate(`\\\\\\hline` = '\\\\') %>%
write_delim(.,path = '.tmp.tex',delim = '&')
# clean last column
n <- names(table) %>% length()
# open latex table
/*typo replace {into ; not ","}*/
Channel
.from( [[1, "ind"], [2, "may"], [3, "nig"], [4, "pue"], [5, "uni"], [6, "gem"]] )
.into{ bel_spec1_ch; bel_spec2_ch }
Channel.from("test1", "test2" ).collect().set{vcf_loc_pair1}
bel_pairs_ch = Channel
.from( "test1" )
.join( vcf_loc_pair1 )
pts <- strata_coordinates( arapat, as.SpatialPoints = TRUE )
stamen_bb <- function(bb){
bt <- pts@bbox %>%
as_tibble()
c(left = bt$min[1],
bottom = bt$min[2],
right = bt$max[1],
top = bt$max[2])
}
---
title: "fit_growth_curve"
author: "Kosmas Hench"
date: "5/24/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(DT)
library(tidyverse)
### nuber of reruns ###
nsims <- 10000
## parameter table defining the parameter space --------------------
params <- tibble(param_name = c("NNIG", "NPUE", "NANC", "TDIV", "TMIG", "MIGRPROBN2P", "MIGRPROBP2N"),
log10min = c(rep(3,3), 1, 1, rep(-5, 2)),
log10max = c(rep(log10(2.5e5), 3), rep(4, 2), rep(-2, 2)),