Skip to content

Instantly share code, notes, and snippets.

View fbrundu's full-sized avatar
💭
I may be slow to respond.

Francesco G. Brundu fbrundu

💭
I may be slow to respond.
View GitHub Profile
@fbrundu
fbrundu / custom.css
Created April 6, 2015 17:17
Custom css for ipython3 notebook
.CodeMirror, div.prompt.input_prompt, div.prompt.output_prompt, pre {
font-family: "Inconsolata for Powerline";
font-size: 100%;
}
<style>
html {
font-size: 62.5% !important; }
body {
font-size: 1.5em !important; /* currently ems cause chrome bug misinterpreting rems on body element */
line-height: 1.6 !important;
font-weight: 400 !important;
font-family: "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
color: #222 !important; }
@fbrundu
fbrundu / tcga_correct_samplenames.py
Created March 5, 2015 14:51
Correct a TCGA assembled tsv file (tab delimited), formatting sample names for tsv columns
import pandas as pd
import sys
import re
tcga_tsv = sys.argv[1]
tcga = pd.read_table(tcga_tsv, sep='\t', index_col=0)
oldcolumns = tcga.columns.tolist()
newcolumns = ['-'.join(re.findall(r'TCGA[^_]*', oc)[0].split('-')[:4])
@fbrundu
fbrundu / l2r_fsel_srs.py
Created February 24, 2015 18:00
Log2ratio transformation, feature selection and simple random sampling on a gene expression matrix
import pandas as pd
import numpy as np
import sys
import random as rnd
csv = sys.argv[1]
out = sys.argv[2]
df = pd.read_table(csv, sep='\t', index_col=0)
@fbrundu
fbrundu / tsv2gct.py
Created February 24, 2015 13:08
Transform tab separated matrix to gct file
import pandas as pd
import sys
import glob
import os
# input / output directory
input_dir = sys.argv[1]
# input file extension
input_ext = sys.argv[2]
# cardinality of index columns (rownames)
@fbrundu
fbrundu / check_unique.sh
Last active August 29, 2015 13:57
Check if a line is composed by unique words.
# line number after ==
# change \\t with the delimiter you want to use instead of tab for splitting to words
words_count=$(awk 'NR==5{print}' data.csv | tr \\t \\n | wc -l)
unique_words_count=$(awk 'NR==5{print}' data.csv | tr \\t \\n | uniq | wc -l)
if [[ "$words_count" -ne "$unique_words_counts" ]]; then
echo "Not unique"
else
echo "Unique"