Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rows <- function(tab, idx=TRUE) { | |
# Set idx to attach an index column | |
if (is.na(tab) || is.null(tab) || nrow(tab) == 0) { | |
return(list()) | |
} | |
lapply(seq_len(nrow(tab)), | |
function(i) { | |
row <- unclass(tab[i,,drop=F]) | |
if (idx) { | |
row$idx <- i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
##################################################### | |
# Name: Bash CheatSheet for Mac OSX | |
# | |
# A little overlook of the Bash basics | |
# | |
# Usage: | |
# | |
# Author: J. Le Coupanec | |
# Date: 2014/11/04 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shortcut for going to work directories | |
# Usage: gw <workdir pattern> | |
# Replace the work directory below as needed | |
# Where workdir pattern is something like "ab/afedeu" | |
function gw { | |
path=`ls --color=none -d /path/to/work/directory/$1*` | |
cd $path | |
} | |
# Go work that fetches work dir from .nextflow.log |
A super short introduction how to call Nim code from R using the .C
interface.
I’m not an R user normally, so I googled and used this post as a
reference:
https://www.r-bloggers.com/three-ways-to-call-cc-from-r/
Let’s define a simple procedure, which we want Nim to do:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*bcftools filter | |
*Filter variants per region (in this example, print out only variants mapped to chr1 and chr2) | |
qbcftools filter -r1,2 ALL.chip.omni_broad_sanger_combined.20140818.snps.genotypes.hg38.vcf.gz | |
*printing out info for only 2 samples: | |
bcftools view -s NA20818,NA20819 filename.vcf.gz | |
*printing stats only for variants passing the filter: | |
bcftools view -f PASS filename.vcf.gz |
TSV means "tab-separated values". I prefer this format over CSV ("comma-separated values") because it doesn't require as much quoting. Many programs that can use CSV formatted data can also use TSV, although they may need to be explicitly told of the different format if it's not detected automatically.
However, in any of the jq scripts below, "@tsv
" can usually be replaced with "@csv
" to get CSV output instead.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
""" | |
Extract title from PDF file. | |
Dependencies: | |
pip install --user unidecode pyPDF PDFMiner | |
Usage: | |
find . -name "*.pdf" | xargs -I{} pdftitle -d tmp --rename {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your key bindings in this file to overwrite the defaults | |
[ | |
// RStudio: Copy lines up/down with alt+cmd+up/down | |
{ | |
"key": "alt+cmd+down", | |
"command": "editor.action.copyLinesDownAction", | |
"when": "editorTextFocus && !editorReadonly" | |
}, | |
{ | |
"key": "shift+alt+down", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import itertools | |
def rle(x): | |
where = np.flatnonzero | |
x = np.asarray(x) | |
n = len(x) | |
if n == 0: | |
return np.array([], dtype=int) | |
starts = np.r_[0, where(~np.isclose(x[1:], x[:-1], equal_nan=True)) + 1] |
NewerOlder