Skip to content

Instantly share code, notes, and snippets.

View johandahlberg's full-sized avatar

Johan Dahlberg johandahlberg

View GitHub Profile
@johandahlberg
johandahlberg / DemoIteratorSkipsRecords.scala
Last active December 25, 2015 12:19
Having problems with the SortingCollection which seems to skip records. Created this gist to use for reference when e-mailing samtools-devel list.
package molmed
import net.sf.samtools.util.SortingCollection
import net.sf.samtools.BAMRecordCodec
import net.sf.picard.fastq.FastqRecord
import java.util.Comparator
import java.io.InputStream
import java.io.PrintStream
import net.sf.picard.fastq.FastqConstants
@johandahlberg
johandahlberg / prepareReference.sh
Created November 5, 2013 16:18
A script for preparing a reference for running with piper on Uppmax.
#!/bin/bash -l
#SBATCH -A b2010028
#SBATCH -p core
#SBATCH -n 2
#SBATCH -t 10:00:00
#SBATCH -J prepare_ref
#SBATCH -o prepare_ref-%j.out
#SBATCH -e prepare_ref-%j.error
# Author: Johan D
@johandahlberg
johandahlberg / contriesAndParticipantsForKP2014.R
Created March 1, 2014 13:15
Just a little visualization of the participants for KP2014.
library(ggplot2)
library(reshape2)
library(maps)
# A tab separated file with contries and participats.
# Note that Unites States needs to be changed to USA and United Kingdom
# to UK.
path.to.contry.and.participants.file <- "~/Desktop/contries.csv"
participants <-
@johandahlberg
johandahlberg / shiny-server.conf
Created March 27, 2014 17:48
My Shiny Server conf
# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location / {
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@johandahlberg
johandahlberg / ParallelShellJobManager.scala
Created February 16, 2015 15:43
Code for a ParallelShellJobRunner for Queue
/*
* Copyright (c) 2012 The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
@johandahlberg
johandahlberg / MinimalKmerProblemExample.scala
Last active August 29, 2015 14:24
Example of java.io.NotSerializableException: org.bdgenomics.formats.avro.NucleotideContigFragment in Adam
package example
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD
import org.bdgenomics.adam.rdd.ADAMContext
import org.bdgenomics.formats.avro.NucleotideContigFragment
/**
* Created by dahljo on 7/14/15.
*/
---
title: Understanding the Rwandan genocide of 1994 through data from the Uppsala Conflict
Data Program
author: "Johan Dahlberg"
date: "October 27, 2015"
output: html_document
licence: http://creativecommons.org/licenses/by-sa/3.0/
---
``` {r, echo=FALSE, message=FALSE}
@johandahlberg
johandahlberg / income_difference.R
Last active December 26, 2015 13:20
Quick plot of income differences between men and women in the period 1991 to 2013 in Sweden.
# Licence:
# https://creativecommons.org/licenses/by/3.0/
library(ggplot2)
library(reshape2)
library(dplyr)
# Data:
# Downloaded at: http://www.statistikdatabasen.scb.se/pxweb/sv/ssd/START__HE__HE0110__HE0110A/SamForvInk2/?rxid=c58583e1-7fc3-418a-9395-0300e138fe7f
# Sammanräknad förvärvsinkomst, medianinkomst för boende i Sverige den 31/12, tkr efter region, kön, ålder och år
@johandahlberg
johandahlberg / performance_test.sh
Created February 11, 2016 14:04
Quick and dirty performance test of proot at Uppmax
echo "Time in container"
for i in $(seq 1 5)
do
/usr/bin/time -f "time: %e" proot -S debian-sid --bind=/proj/a2009002/webexport/opendata/HiSeqX_CEPH/CEP-13-3/03-BAM/ samtools mpileup -r 22:1-23096112 /proj/a2009002/webexport/opendata/HiSeqX_CEPH/CEP-13-3/03-BAM/CEP-13-3.clean.dedup.recal.bam 2>&1 > test.pileup | grep time
done
echo "Time outside container"
for i in $(seq 1 5)
do
/usr/bin/time -f "time: %e" samtools mpileup -r 22:1-23096112 /proj/a2009002/webexport/opendata/HiSeqX_CEPH/CEP-13-3/03-BAM/CEP-13-3.clean.dedup.recal.bam 2>&1 > test.pileup | grep time