Skip to content

Instantly share code, notes, and snippets.

@sahilseth
sahilseth / custom R funcs.R
Created November 13, 2015 22:02
list or functions in R
a<-1:5
fn<-lapply(a, function(i) {
force(i)
function(x) {
x * i
}
})
@sahilseth
sahilseth / git_cmds
Last active November 13, 2015 17:27
My list of git commands
# clone
git clone source
# add changes to be committed
git add .
git commit -m "my message"
git push
@sahilseth
sahilseth / gist:78721eada1f0007c7afd
Created November 12, 2015 16:40
db nfsp information
dbNSFP version 3.0b2a
Release:
April 12, 2015
Major sources:
Variant determination:
Gencode release 22/Ensembl 79, released March, 2015 (hg38)
Functional predictions:
SIFT ensembl 66, released Jan, 2015 http://provean.jcvi.org/index.php
@sahilseth
sahilseth / graph_rfuncs.R
Created November 6, 2015 05:52
create a plot of functions
# http://www.r-bloggers.com/r-function-of-the-day-foodweb/
#install.packages("mvbutils")
library(mvbutils)
foodweb()
@sahilseth
sahilseth / identify_large_files.sh
Last active August 5, 2018 10:07
At times .git folder becomes much larger than the code base, and needs shrinking
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
@sahilseth
sahilseth / rscript_cmd.sh
Created November 3, 2015 19:48
Storing output from Rscript
Rscript wrangl_00_run_htseq.R | tee wrangl_00_run_htseq.Rout
@sahilseth
sahilseth / gtf_add_chr.sh
Created November 3, 2015 18:28
Adding chr to a GTF file
awk '{ if($1 !~ /^#/){print "chr"$0} else{print $0} }' Homo_sapiens.GRCh37.75.gtf
@sahilseth
sahilseth / subset_tsv.sh
Last active March 21, 2016 16:54
subset a tsv file using R. In this example, get a list of errored commands in flowr.
# idea is to, first filter based on a condition, and then display the results
Rscript -e 'library(dplyr);params::read_sheet("flow_details.txt") %>% filter(exit_code>0)' | less
# we add select, to show only a few columns:
Rscript -e 'library(dplyr);params::read_sheet("flow_details.txt") %>% filter(exit_code>0) %>% select(jobname, jobnm, num, exit_code, cmd)' | less
# add kable, to show results in a markdown format:
Rscript -e 'library(dplyr);library(params);read_sheet("flow_details.txt") %>% filter(exit_code>0) %>% select(jobname, jobnm, num, exit_code, cmd)%>% kable()' | less
@sahilseth
sahilseth / issue with
Created October 27, 2015 18:05
issue with dplyr
log2(as.numeric(select(clust, PATC53.377)[1,]) / as.numeric(select(clust, one_of(newrefs))[1,]))
VS
as.numeric(select(clust, PATC53.377)[1,]) / as.numeric(select(clust, one_of(newrefs))[1,]) %>% log2()
@sahilseth
sahilseth / fix brew.sh
Last active September 24, 2017 18:49
fix issues with brew
# http://stackoverflow.com/questions/14113427/brew-update-failed
cd $(brew --prefix)
git reset --hard HEAD
# cellar on hpcc cluster
# --prefix=~/.linuxbrew/Cellar
git clean -df
brew update