Skip to content

Instantly share code, notes, and snippets.

Avatar

André F. Rendeiro afrendeiro

View GitHub Profile
@afrendeiro
afrendeiro / make_validate_pdfa_muw.sh
Created Sep 27, 2019
An example of how to create an validate a PDF/A compatible file for submission as a thesis at the Medical University of Vienna
View make_validate_pdfa_muw.sh
#!/usr/bin/bash
# This script details an example of how to create an validate a PDF/A
# compatible PDF file for submission as a thesi at the Medical University
# of Vienna
# It assumes in the working directory there are ${PAPER}.initial.pdf files
# that will make up your cumulative thesis
# The first cause of failure for PDF/A compatibility is the PDFs from your
@afrendeiro
afrendeiro / chipseq_pipeline.py
Created Sep 26, 2019
An old pipeline for ChIP-seq/ChIPmentation data processing used back in 2014. Uploading for preservation
View chipseq_pipeline.py
#!/usr/bin/env python
"""
ChIP-seq pipeline
"""
from argparse import ArgumentParser
import os
import sys
import logging
@afrendeiro
afrendeiro / distributions_gini_lorenz_curves.py
Created Sep 19, 2019
Visualizing the relationship between distributions and gini coefficient with Lorenz curves
View distributions_gini_lorenz_curves.py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def gini(x):
# Mean absolute difference
mad = np.abs(np.subtract.outer(x, x)).mean()
# Relative mean absolute difference
rmad = mad / np.mean(x)
@afrendeiro
afrendeiro / 10Xfastq_to_bam.py
Last active May 21, 2019
Convert 10X FASTQ files to single end BAM file with barcodes annotated as tags. Useful for pipelines using BAM format as input (e.g. STAR mapping, featureCounts quantification)
View 10Xfastq_to_bam.py
#! /usr/bin/env python
"""
Convert 10X FASTQ files to single end BAM file with barcodes annotated as tags
"""
from argparse import ArgumentParser
from glob import glob
@afrendeiro
afrendeiro / keybase.md
Created Mar 12, 2019
keybase confirmation
View keybase.md

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:

@afrendeiro
afrendeiro / add_tracking_to_scanpy.py
Last active Feb 10, 2019
Add a "tracker" attribute to AnnData objects to keep track of transformations to it's data
View add_tracking_to_scanpy.py
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 / simple_score_within_signature.py
Created Jan 25, 2019
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)
View simple_score_within_signature.py
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 / fasta.fa
Last active Jan 10, 2019
pybedtools error related to pybedtools#147
View fasta.fa
>chr1
ATGCATGCATGCATGCATGCATGCATGCATGCATGCATGC
ATGCATGCATGCATGCATGCATGCATGCATGCATGCATGC
View plot_homer_consensus.py
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 / process_figures_for_paper.sh
Last active Aug 11, 2020
Convert SVG figures to high quality raster and aggregated pdfs - labeled and unlabeled figures will be produced
View process_figures_for_paper.sh
#!/usr/bin/env bash
# Dependencies:
# 1. inkscape
# 2. pdfunite
# 3. (optinal) minify (https://github.com/tdewolff/minify/tree/master/cmd/minify)
# `sudo apt install minify`
# Assumptions:
# 1. figures are made in SVG format