Skip to content

Instantly share code, notes, and snippets.

View afrendeiro's full-sized avatar

André F. Rendeiro afrendeiro

View GitHub Profile
@afrendeiro
afrendeiro / process_csv.py
Last active March 26, 2018 14:37
Parse raw data out of CSV files exported from a Thrombin Generation Assay (TGA)
import os
import pandas as pd
from argparse import ArgumentParser
# Parse command-line arguments
parser = ArgumentParser(
prog="CSV parser",
description="Gets some column out of CSVs."
)
@afrendeiro
afrendeiro / get_bioinfo_files.sh
Last active September 17, 2018 19:20
Get static files used in bioinformatics (genomes, indexes, annotations)
for GENOME in hg19 mm10 danRer10
do
# Static files
mkdir -p resources/${GENOME}
cd resources/${GENOME}
### Genome
wget http://hgdownload.cse.ucsc.edu/goldenPath/${GENOME}/bigZips/${GENOME}.2bit
twoBitToFa ${GENOME}.2bit ${GENOME}.fa
samtools faidx ${GENOME}.fa
cd ../..
@afrendeiro
afrendeiro / run_zinba.R
Created April 27, 2015 12:05
Running the ZINBA peak caller
# Install zimba
R
install.packages(c("R.oo"))
install.packages(c("R.utils", "quantreg","doParallel","doMC","foreach")) # for R>3.0
# only version that works with R 3.0:
# get it from here: https://code.google.com/p/zinba/issues/detail?id=69
install.packages("zinba_2.03.1.tar.gz", repos=NULL)
# Make bed files from bams
# system("bedtools bamtobed -i /data/mapped/sample.bam > ~/zinba/reads/sample.bed")
@afrendeiro
afrendeiro / figure_convert_NPG2CellPress.sh
Last active December 12, 2018 13:30
Convert SVG figures from Nature Publishing Group to CellPress style, generate high quality raster and aggregated pdfs
CURRENT_DATE=20181212
NUMBER_MAIN_FIGURES=5
NUMBER_SUPP_FIGURES=11
ROOT_DIR=/home/path/to/paper/figures
cd $ROOT_DIR
mkdir -p cropped_unlabeled_pngs
# Cell Press format convertion
@afrendeiro
afrendeiro / figure_convert_CellPress2NPG.sh
Last active December 12, 2018 13:33
Convert SVG figures from CellPress style to Nature Publishing Group style, generate high quality raster and aggregated pdfs
# Change this
CURRENT_DATE=20181212
NUMBER_MAIN_FIGURES=5
NUMBER_SUPP_FIGURES=11
ROOT_DIR=/home/path/to/paper/figures
# Don't change this
cd $ROOT_DIR
mkdir -p cropped_unlabeled_pngs
def plot_differential_enrichment(
enrichment_table,
enrichment_type,
data_type="ATAC-seq",
direction_dependent=True,
output_dir="results/differential_analysis_{data_type}/enrichments",
comp_variable="comparison_name",
output_prefix="differential_analysis",
rasterized=True,
@afrendeiro
afrendeiro / fasta.fa
Last active January 10, 2019 16:31
pybedtools error related to pybedtools#147
>chr1
ATGCATGCATGCATGCATGCATGCATGCATGCATGCATGC
ATGCATGCATGCATGCATGCATGCATGCATGCATGCATGC
@afrendeiro
afrendeiro / simple_score_within_signature.py
Created January 25, 2019 15:01
Simple method to score each sample withing the boundaries of a signature containing two blocks (e.g. gene expression signature with up- and down-regulated genes)
import pandas as pd
from sklearn.preprocessing import StandardScaler
# get list of genes of interest (e.g. from diff exp, or a known signature)
diff = pd.Index(['geneX', 'geneY'])
# X is our numeric matrix, shape (n_features, n_samples)
X = pd.DataFrame(index=['geneA', 'geneZ'], columns=['stimul_1', 'stimul_2'] + ['unstimul_1', 'unstimul_2'])
# Standardize and center
@afrendeiro
afrendeiro / add_tracking_to_scanpy.py
Last active February 10, 2019 11:00
Add a "tracker" attribute to AnnData objects to keep track of transformations to it's data
import scanpy.api as sc
import numpy as np
def add_tracker(field_name="tracker"):
from inspect import getcallargs
from functools import wraps
def tracker(f):
@wraps(f)
def wrapper(*args, **kwds):
@afrendeiro
afrendeiro / keybase.md
Created March 12, 2019 08:27
keybase confirmation

Keybase proof

I hereby claim:

  • I am afrendeiro on github.
  • I am afrendeiro (https://keybase.io/afrendeiro) on keybase.
  • I have a public key ASCLj9Mi9QyGyaS_Ez-M1L2daTExlulKnwG2ltgD_v_mNwo

To claim this, I am signing this object: