Skip to content

Instantly share code, notes, and snippets.

Avatar
:electron:
nextflow, R, shiny, shell

Angel Angelov angelovangel

:electron:
nextflow, R, shiny, shell
  • Germany
View GitHub Profile
@angelovangel
angelovangel / md5sum_manyfiles.sh
Last active Mar 26, 2021
checksum many files
View md5sum_manyfiles.sh
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 Feb 12, 2020
SI prefixes with printf
View prefix-printf.md

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

printf '%#d\n' 105000000
105M

Even this!!!

View Leaflet-R-hotline-demo.R
# 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
View FACS data plotting (geom_hex)
# 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 Nov 23, 2017
Fit dose-response models (with drc) and plot, for many samples
View do_drm.R
# 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 Jun 2, 2022
Using models from the drc package (for dose-response curves) with ggplot
View Using models from the drc package 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 Oct 29, 2017
plotting linear models plus the model coefficients
View linear model plot with 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 Feb 2, 2017
GCMS analysis of olefins in R (specific for Shimadzu GCMS Postrun output)
View olefins-analysis.R
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)