Monday, August 22, 2016

Multi-value grep/match in R

> df<-data.frame(names=c("a","b","c"),age=c(1,2,3))
> df
names age
1 a 1
2 b 2
3 c 3
values_to_grep<-c("a","b")
> unique (grep(paste(values_to_grep,collapse="|"),
+ df$names, value=TRUE))
[1] "a" "b"

Sunday, August 21, 2016

Uploading large files to Github

Git Large File Storage : https://git-lfs.github.com/

Very useful if you want to store images / genome indexes etc.

Wednesday, March 30, 2016

Reading space-separated key:value text file into bash array

# param1 : name of text file
declare -A myArray
filename="$1"
while read -r line
do
name="$line"
name=($name)
myArray[${name[0]}]=${name[1]}
done < "$filename"
view raw txt2array.sh hosted with ❤ by GitHub

Monday, March 28, 2016

Using pip to install Python dependencies

Recently I ran into problems of incompatibilities in dependencies, especially when running Python-based scripts (numpy & pandas, essentially the scipy suite).

The easiest way to avoid these troubles (I hope it works for you too!) is to install them using pip rather than your Linux distributions repository (eg. through Ubuntu's apt-get install).