Skip to content

Instantly share code, notes, and snippets.

View gatoravi's full-sized avatar

Avinash R gatoravi

View GitHub Profile
@gatoravi
gatoravi / run_em.R
Created April 20, 2015 05:30
EM algorithm - solution to problem 6.6.7 "Intro to Mathematical Statistics - Hogg, 7th ed"
#! /bin/Rscript
run_em <- function(data, cutoff = 1.50, theta_init = 0.5, iter = 100, tolerance = 1e-4) {
missing = data[data == cutoff]
observed = data[data != cutoff]
n1 = length(observed)
n2 = length(missing)
n = n1 + n2
theta_current = theta_init
theta_new = 0
@gatoravi
gatoravi / import-model-define.sh
Last active August 29, 2015 14:16
define models for imported instrument data.
#List all the instrument-data that is imported
genome instrument-data list imported "sample.patient.common_name='TST1ds' and sample.extraction_type = 'genomic dna'"
genome instrument-data list imported "sample.patient.common_name='TST1ds' and sample.extraction_type = 'rna'"
#Define the models based on imported instrument-data, rename the ID's
genome model define rna-seq --reference-sequence-build='106942997' --annotation-build='124434505' --cancer-annotation-db='tgi/cancer-annotation/human/build37-20131010.1' --subject='H_NJ-HCC1395ds-HCC1395_RNA' --processing-profile='2762841' --instrument-data='0296e0aeeb3f4daab1e8604cddb2cb70' --model-name='hcc1395ds-tumor-rnaseq'
genome model define rna-seq --reference-sequence-build='106942997' --annotation-build='124434505' --cancer-annotation-db='tgi/cancer-annotation/human/build37-20131010.1' --subject='H_NJ-HCC1395ds-HCC1395_BL_RNA' --processing-profile='2762841' --instrument-data='675561c466744c8498f903b77ee9acbe' --model-name='hcc1395ds-normal-rnaseq'
ge
@gatoravi
gatoravi / workflow_example.pm
Last active August 29, 2015 14:15
An example workflow on TGI's GMS.
sub _run_workflow {
my $self = shift;
my $lsf_queue = $ENV{GENOME_LSF_QUEUE_BUILD_WORKER_ALT};
my $lsf_project = 'varscan_filter';
my $w = Workflow::Operation->create(
name => "Filter Varscan SNVs",
operation_type => Workflow::OperationType::Command->get(
'Genome::Model::Tools::Capture::FormatSnvs')
);
@gatoravi
gatoravi / kMerAnalysis.chr22.null.v6.sh
Last active May 13, 2017 05:02
A script to generate kmer counts in a region for trios.
#Avinash Ramu, Conrad Lab, WUSTL
#Estimate the kmer statistic in a specified window
#use overlapping windows to capture the kmers at the edges. Make sure the start of the read lies within the window.
#Arguments - a region in the form "chr\tstart\tstop" i.e $1=chr $2=start $3=end
#Updates
#modified - 6/13 made it $6 - ($7 + $8 ) in other words I removed /2
#modified - 6/14 cleanup the code.
#modified - 6/19 add a column for the reference kmer counts
@gatoravi
gatoravi / Cnmops.R
Created August 14, 2014 21:45
Somatic (tumor vs normal) copy number calling with CnMops
#!/usr/bin/env Rscript
library(cn.mops)
usage <- function()
{
writeLines("Usage:\n\tRscript Cnmops.pm.R tumor.bam normal.bam capture.bed outdir --test[or --notest]")
}
convert_start_end_character <-function(t) {
t$start <- sprintf("%d", t$start)
# load up area shape file:
library(maptools)
area <- readShapePoly("ne_10m_parks_and_protected_lands_area.shp")
# # or file.choose:
# area <- readShapePoly(file.choose())
library(RColorBrewer)
colors <- brewer.pal(9, "BuGn")
@gatoravi
gatoravi / index.html
Created April 8, 2014 20:06
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
@gatoravi
gatoravi / tumorVsNormals.captureRegions.R
Last active August 29, 2015 13:56
tumorVsNormals.captureRegions.R
usage <- function()
{
writeLines("Usage:\n\tRscript tumorVsNormal.R tumor.bam normal.bam capture.bed")
}
args <- commandArgs(trailingOnly = TRUE)
if(length(args) != 3) {
usage()
quit()
@gatoravi
gatoravi / python_example.py
Last active August 29, 2015 13:56
Python example to use the DGIdb API
#!/usr/bin/env python
#This example uses the 'requests' library
#To install requests:
# sudo pip install requests
#If you don't have pip:
# see http://www.pip-installer.org/en/latest/installing.html
# or
# wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
# sudo python get-pip.py
@gatoravi
gatoravi / tumorVsNormal.R
Created February 21, 2014 20:58
tumorVsNormal.R
usage <- function()
{
writeLines("Usage:\n\tRscript tumorVsNormal.R tumor.bam normal.bam chromosome")
}
args <- commandArgs(trailingOnly = TRUE)
if(length(args) != 3) {
usage()
quit()