Skip to content

Instantly share code, notes, and snippets.

View dakl's full-sized avatar
💌
ML Engineer @ Epidemic Sound

Daniel Klevebring dakl

💌
ML Engineer @ Epidemic Sound
  • Epidemic Sound
  • Stockholm
View GitHub Profile
# This function takes A and M-values (or any X and Y )
lowessNormalization <- function(x, y, include = TRUE, line = NULL,
...) {
isFinite <- (is.finite(x) & is.finite(y))
if (any(isFinite)){
if (is.null(line)) {
line <- lowess(x[isFinite & include], y[isFinite &
include], ...)
}
y[isFinite] <- y[isFinite] - approx(line, xout = x[isFinite],
lowessNormalization <- function(x, y, include = TRUE, line = NULL,
...) {
isFinite <- (is.finite(x) & is.finite(y))
if (any(isFinite)){
if (is.null(line)) {
line <- lowess(x[isFinite & include], y[isFinite &
include], ...)
}
y[isFinite] <- y[isFinite] - approx(line, xout = x[isFinite],
ties = mean)$y
lowessNormalization <- function(x, y, include = TRUE, line = NULL,
...) {
isFinite <- (is.finite(x) & is.finite(y))
if (any(isFinite)){
if (is.null(line)) {
line <- lowess(x[isFinite & include], y[isFinite &
include], ...)
}
y[isFinite] <- y[isFinite] - approx(line, xout = x[isFinite],
ties = mean)$y
# filter flags
ff <- function(f, flags){
## if !all(dim(mat) == dim(flags)) break say "data and flags must have identical dimensions"
for(k in 1:ncol(f)){
idx.flags <- which( flags[,k] < 0 )
f[idx.flags,k] <- NA
cat("Number features filtered on slide ", k, ": ", length(idx.flags), "\n", sep="")
}
f
}
@dakl
dakl / memusg
Created February 18, 2013 08:37 — forked from netj/memusg
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <[email protected]>
# Created: 2010-08-16
set -um
# check input
[ $# -gt 0 ] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; }
@dakl
dakl / -
Created September 24, 2014 07:04
From 5f60239292d8d963997aeb14201e2e9eb2635c63 Mon Sep 17 00:00:00 2001
From: Daniel Klevebring <[email protected]>
Date: Wed, 24 Sep 2014 06:42:15 +0000
Subject: [PATCH] added quotes around to build on centos 6.5
---
Analysis/CMakeLists.txt | 2 +-
buildTools/cmake/CMakeLists.compiler.txt | 4 ++--
buildTools/cmake/CMakeLists.dependencies.txt | 26 +++++++++++++-------------
buildTools/cmake/CMakeLists.version.txt | 6 +++---
circle <- function(x, y, r, ...) {
ang <- seq(0, 2*pi, length = 100)
xx <- x + r * cos(ang)
yy <- y + r * sin(ang)
polygon(xx, yy, ...)
}
venndia <- function(A, B, C, alab="A", blab="B", clab="C", getdata=FALSE, cex.text=2, cex.num=2, plot=TRUE, xlim=c(0,9), ylim=c(0,9), ...){
cMissing <- missing(C)
if(cMissing){ C <- c() }
@dakl
dakl / brew install sailfish -v
Created October 23, 2014 11:56
log from running `brew install sailfish -v`
$ brew install sailfish -v
tbb: OS X Lion or newer is required.
==> Downloading https://github.com/kingsfordgroup/sailfish/releases/download/v0.6.2/Sailfish-0.6.2-Source.tar.gz
Already downloaded: /home/kleve/.cache/Homebrew/sailfish-0.6.2.tar.gz
==> Verifying sailfish-0.6.2.tar.gz checksum
tar xf /home/kleve/.cache/Homebrew/sailfish-0.6.2.tar.gz
==> cmake .. -DCMAKE_INSTALL_PREFIX=/gulo/glob/kleve/private/linuxbrew/Cellar/sailfish/0.6.2 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev
-- The C compiler identification is GNU 4.9.1
-- The CXX compiler identification is GNU 4.9.1
-- Check for working C compiler: /gulo/glob/kleve/private/linuxbrew/bin/gcc-4.9
# This function sorts the matrix for better visualization of mutual exclusivity across genes
memoSort <- function(M) {
geneOrder <- sort(rowSums(M), decreasing=TRUE, index.return=TRUE)$ix;
scoreCol <- function(x) {
score <- 0;
for(i in 1:length(x)) {
if(x[i]) {
score <- score + 2^(length(x)-i);
}
}
@HD VN:1.4 SO:coordinate
@SQ SN:chrM LN:16571
@SQ SN:chr1 LN:249250621
@SQ SN:chr2 LN:243199373
@SQ SN:chr3 LN:198022430
@SQ SN:chr4 LN:191154276
@SQ SN:chr5 LN:180915260
@SQ SN:chr6 LN:171115067
@SQ SN:chr7 LN:159138663
@SQ SN:chr8 LN:146364022