Skip to content

Instantly share code, notes, and snippets.

Avatar

André F. Rendeiro afrendeiro

View GitHub Profile
@afrendeiro
afrendeiro / seaborn_clustermap_with_effortless_colorbars_decorator.ipynb
Last active May 14, 2020
Seaborn clustermap with effortless row and column colorbars
View seaborn_clustermap_with_effortless_colorbars_decorator.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afrendeiro
afrendeiro / easier_pandas_multiindex_getitem.py
Last active May 11, 2020
Easier access to pandas.MultiIndex values circumventing get_level_values
View easier_pandas_multiindex_getitem.py
import pandas as pd
import seaborn as sns
class Loc:
def __init__(self, pandas_obj):
self._obj = pandas_obj
def __getitem__(self, x):
return pd.Index(self._obj.index.to_frame().loc[x])
@afrendeiro
afrendeiro / guides_to_ref.py
Created Jan 14, 2020
Build a transcriptome reference with additional chromosomes for CRISPR gRNA constructs
View guides_to_ref.py
#!/usr/bin/env python
"""
This script generates a transcriptome reference with additional
scaffolds/chromosomes for CRISPR gRNA constructs.
"""
import sys
import os
from argparse import ArgumentParser
@afrendeiro
afrendeiro / create_reference_genome_mixtures.py
Last active Oct 30, 2019
This script creates reference genome indexes with mixtures of organisms/assemblies
View create_reference_genome_mixtures.py
#!/usr/bin/env python
"""
This script creates reference genomes with mixtures of organisms/assemblies.
"""
import sys
import os
import argparse
@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):