Skip to content

Instantly share code, notes, and snippets.

View angelovangel's full-sized avatar
:electron:
nextflow, R, shiny, shell

Angel Angelov angelovangel

:electron:
nextflow, R, shiny, shell
  • Germany
View GitHub Profile
@angelovangel
angelovangel / args_script_template.sh
Created September 12, 2023 13:34 — forked from rragundez/args_script_template.sh
Template of bash script with mandatory and optional arguments
#!/bin/bash
set -e
usage="$(basename "$0") [-h] [-i PROJECT] [-v VM] [-p PYTHON] [-d NOTEBOOKS]
Make a user provide SSH key and jupyter notebooks (in roles/bootstrap/files/notebooks) to each user listed in var/common.yml
where:
-h show this help text
-i google cloud project id
-v name of instance/virtual machine
-p python path
@angelovangel
angelovangel / md5sum_manyfiles.sh
Last active March 26, 2021 16:20
checksum many files
Generate checksums for many files in a directory
```
# make checksums (use md5 on macos)
find ./some_dir -type f -exec md5sum {} \; >> checksums.md5
# check them
md5sum -c checksums.md5
# use gnu parallel for really many files? Much faster
@angelovangel
angelovangel / prefix-printf.md
Last active February 12, 2020 20:56
SI prefixes with printf

In ksh only (not in bash), this just works:

printf '%#d\n' 105000000
105M

Even this!!!

@angelovangel
angelovangel / Leaflet-R-hotline-demo.R
Last active March 27, 2021 09:34
Leaflet hotline demo
# demonstrate Leaflet.hotline JS plugin in leaflet for R
library(leaflet)
library(htmlwidgets)
library(htmltools)
#library(mapview)
# the Leaflet.hotline plugin has to be locally downloaded
@angelovangel
angelovangel / FACS data plotting (geom_hex)
Last active June 23, 2023 13:43
FACS data plotting
# this code is about
# reading fcs files (from FACS) and converting them to one dataframe
# plotting is then done normally in ggplot
# installation instructions for the required libraries can be found on the internet:)
library(flowCore)
library(tidyverse)
### this function reads a fcs file and returns the data as a tibble, adding a column with the file name #####
@angelovangel
angelovangel / do_drm.R
Last active January 23, 2024 11:36
Fit dose-response models (with drc) and plot, for many samples
# these two functions perform the following:
# do_drm() --> performs drm (from the drc package) on a long dataframe, using the LL.4 log-logistic model for describing dose-response relationships
# do_drm_plot() --> plots the output of do_drm()
# to use the functions just paste this file in your R session and source it.
# try it out with
# do_drm(S.alba, Dose, DryMatter, Herbicide) %>% do_drm_plot(ed50 = TRUE, color = ~Herbicide) + scale_x_log10()
##=====================
# do_drm() usage
# do_drm(df, d, r, x, y, ...)
@angelovangel
angelovangel / Using models from the drc package with ggplot
Last active June 23, 2023 13:43
Using models from the drc package (for dose-response curves) with ggplot
# the aim is to use the 'drc' package to fit models to data and then extract the data and use for plotting in ggplot
# the data could be growth curves, dose-response, Michaelis-Menten etc.
# here, the S.alba data from drc is used for dose-response
library(tidyverse)
library(broom)
library(drc)
library(modelr)
attach(S.alba) # the data used in this gist
library(egg)
@angelovangel
angelovangel / linear model plot with coefficients
Last active October 29, 2017 21:56
plotting linear models plus the model coefficients
# a general function for plotting linear models
# makes plots of the data and the model plus the model coefficients
# the function takes a linear model object as argument
ggplotLM <- function(fit) {
require(ggplot2)
require(broom)
@angelovangel
angelovangel / olefins-analysis.R
Created February 2, 2017 14:33
GCMS analysis of olefins in R (specific for Shimadzu GCMS Postrun output)
library(ggplot2)
library(dplyr)
library(reshape2)
#df
n <- as.integer(grep("Header", readLines("ASCIIData.txt")) %>% length()) # number of runs, without the system call above
ole <- readline(prompt="Enter number of olefins detected for these runs(including C30): ")
ole <- as.integer(ole)