Skip to content

Instantly share code, notes, and snippets.

@lukauskas
lukauskas / lux-api-Series-unique-bug.ipynb
Created March 15, 2022 12:36
A gist illustrating the lux bug for pd.Series unique function
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Cavadas et al., Scientific Reports, 2016 Supplements

This gist pre-processes supplementary data from Cavadas et al. paper in Scientific Reports, citation below:

Cavadas, M.A.S., Mesnieres, M., Crifo, B., Manresa, M.C., Selfridge, A.C., Keogh, C.E., Fabian, Z., Scholz, C.C., Nolan, K.A., Rocha, L.M.A., et al. (2016). REST is a hypoxia-responsive transcriptional repressor. Sci Rep-Uk 6, 31355

Each of the notebooks downloads the data directly from the journal, converts it into an easier-to-work tsv format, and augments it with uniprot, ensembl and entrez identifiers.

The notebooks make extensive use of MyGene.info which can be cited as:

@lukauskas
lukauskas / a-scipy-1.6.1-slow-spermanr-with-nans.ipynb
Last active March 13, 2021 09:09
Gist for degraded performance of spearmanr in scipy 1.6.1, issue https://github.com/scipy/scipy/issues/6654
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lukauskas
lukauskas / transcript_bed_to_tss_bed.py
Last active September 3, 2020 15:17
Convert gene/transcript bed file to a TSS bed file using `pandas`
import pandas as pd
def transcript_to_tss(transcript_bed, tss_bed):
"""
Convert transcript bed file to TSS bed file
Strand aware
"""
# Read bedfile to pandas
df = pd.read_csv(transcript_bed,
@lukauskas
lukauskas / density_scatter.py
Last active September 10, 2020 18:06
Density scatterplots using Turbo colormap from google
from matplotlib import pyplot as plt
import numpy as np
from scipy.interpolate import interpn
# Density scatterplots, based on https://stackoverflow.com/a/53865762
def density_scatterplot(x, y, bins=100, cmap='turbo', drop_na=True, ax=None, **kwargs):
if ax is None:
ax = plt.gca()
x = np.asarray(x)
y = np.asarray(y)

Stoltzman et al. PNAS 2008 Figure S1

This Github gist contains a CSV file of manually transcribed gene names from Figure S1 of Stoltzman et al. 2008 PNAS paper.

Another file containing the ENSEMBL gene identifiers matched to these ids has been produced via mygene.info API (Xin,2016)

References

  • Stoltzman, C., Peterson, C., Breen, K., Muoio, D., Billin, A., Ayer, D. (2008). Glucose sensing by MondoA:Mlx complexes: A role for hexokinases and direct regulation of thioredoxin-interacting protein expression Proceedings of the National Academy of Sciences 105(19), 6912-6917. https://dx.doi.org/10.1073/pnas.0712199105
@lukauskas
lukauskas / deeeptools-matrix-to-dataframe.md
Last active November 12, 2020 19:15
Converting deeptools matrix to a pandas dataframe

Converting deeptools matrix to pd.DataFrame

import matplotlib

# Deeptools will mess with matplotlib settings, fix that
_mpl_backend = matplotlib.rcParams['backend']
from deeptools.heatmapper import heatmapper as deeptools_heatmapper
matplotlib.use(_mpl_backend)
del _mpl_backend