Skip to content

Instantly share code, notes, and snippets.

View johandahlberg's full-sized avatar

Johan Dahlberg johandahlberg

View GitHub Profile
@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.
*/
@johandahlberg
johandahlberg / ReplaceSampleNameInReadGroup.java
Created September 11, 2012 12:46
A Picard class for switching read names according to a translation table in a white space separated file.
package net.sf.picard.sam;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@johandahlberg
johandahlberg / gist:4058394
Created November 12, 2012 09:42
Working document for Scala/GATK/Queue setup guide.
*----------------------------------
* Setting up git
*----------------------------------
Clone gatk git repo
Add the main gatk repo as a upstream remote repo:
git remote add upstream https://github.com/broadgsa/gatk.git
Change the remote of the master branch to upstream. .git/config should look like this.
#!/usr/bin/python
import os
def get_immediate_subdirectories(dir):
return [name for name in os.listdir(dir)
if os.path.isdir(os.path.join(dir, name))]
# Get runfolder name from file and return as list.
def get_runfolders_already_run(file):
---
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 / SimpleBWT
Last active December 12, 2015 04:49
Naive functional implementation of Burrows-Wheels transform in scala
import scala.math.Ordering
object SimpleBW extends App {
def bwt(s: String): String = {
def tranformString(string: String): List[String] = { transformString(string, string.length) }
def transformString(string: String, splitIndex: Int): List[String] = {
if (splitIndex == 0) {
// Recursion base case