Skip to content

Instantly share code, notes, and snippets.

Avatar

Nezar Abdennur nvictus

View GitHub Profile
@nvictus
nvictus / read_motifs.py
Last active Jun 16, 2020
motif PFM/PWM dataframe reader
View read_motifs.py
import numpy as np
import pandas as pd
def _probability_mat_to_information_mat(prob_df, bg_df):
"""
Converts a probability matrix to an information matrix.
Taken from logomaker (https://github.com/jbkinney/logomaker).
"""
@nvictus
nvictus / preferred.py
Last active Jun 13, 2020
preferred numbers
View preferred.py
def geomprog(start, mul):
"""
Generate a geometric progression.
Beginning with integer `start`, generate an unbounded geometric
progression with ratio `mul`.
"""
start = int(start)
yield start
@nvictus
nvictus / mutual_info.py
Created Mar 16, 2020 — forked from GaelVaroquaux/mutual_info.py
Estimating entropy and mutual information with scikit-learn
View mutual_info.py
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
These computations rely on nearest-neighbor statistics
'''
import numpy as np
@nvictus
nvictus / godsnot.json
Created Dec 24, 2019
A large palette of reasonably distinct colors
View godsnot.json
[
"#000000",
"#FFFF00",
"#1CE6FF",
"#FF34FF",
"#FF4A46",
"#008941",
"#006FA6",
"#A30059",
"#FFDBE5",
@nvictus
nvictus / pandas_jupyter_paginator.py
Last active Jan 22, 2020 — forked from nokados/pandas_jupyter_paginator.py
Paginator for pandas.DataFrame in Jupyter Notebook
View pandas_jupyter_paginator.py
"""
Forked from: https://gist.github.com/nokados/e8f0a64b55099f2f07a50f2b090c91c7
Changes
* Added slider control to scroll through pages of really large dataframes.
* Reduce flicker by making events trigger widget element updates instead of
clearing output and re-rendering.
* Add support for dataframe CSS styling.
* Register custom pandas accessor
@nvictus
nvictus / cool.r
Last active Oct 25, 2019
coolR: a cooler reader for R
View cool.r
# Notes
# -----
# * Cooler's stored bin IDs are 0-based. However, for consistency with R, this API should take
# 1-based indexing as input for table row and matrix range queries.
# * See Ilya's implementation: https://github.com/dozmorovlab/HiCcompare/issues/9
library(hdf5r)
library(dplyr)
library(tibble)
library(purrr)
library(data.table)
@nvictus
nvictus / .inputrc
Last active May 1, 2018
linux inputrc
View .inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@nvictus
nvictus / load-dense-contact-matrix.ipynb
Last active Jul 16, 2017
load dense contact matrix
View load-dense-contact-matrix.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nvictus
nvictus / tbwarn.py
Last active Jun 20, 2017
print traceback in warnings
View tbwarn.py
import traceback
import warnings
import sys
def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
log = file if hasattr(file,'write') else sys.stderr
traceback.print_stack(file=log)
log.write(warnings.formatwarning(message, category, filename, lineno, line))
View zarr-s3.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.