Skip to content

Instantly share code, notes, and snippets.

View lucananni93's full-sized avatar
🖥️
Working

Luca Nanni lucananni93

🖥️
Working
View GitHub Profile
@lucananni93
lucananni93 / quantile_normalization.py
Created May 28, 2019 11:57
Quantile Normalization using Numpy
import numpy as np
def quantile_normalization(m):
sort_idx = np.argsort(m, axis=0)
ranks = np.argsort(sort_idx, axis=0)
sorted_cols = np.sort(m, axis=0)
col_ranks = sorted_cols.mean(1)
qnorm = col_ranks[ranks]
return qnorm
@lucananni93
lucananni93 / 0_deploy_feature_branches_travis.md
Last active June 16, 2019 10:35
Deploy to multiple snapshot repositories based on the git branch (with Travis) in a multi-module project

Deploy to multiple snapshot repositories based on the git branch (with Travis) in a multi-module project

You have a multi-module maven project which is structured like this:

project/
  pom.xml
  module1/
    pom.xml
    other_stuff/
 module2/
@lucananni93
lucananni93 / triangluar_heatmap.py
Created November 1, 2017 15:49
Create a triangular correlation plot (triangular heatmap)
import numpy as np
import seaborn as sns
from scipy.ndimage import rotate
def plot_heatmap_triu(m, shape=(10,10)):
"""
Plot a symmetric matrix as a triangluar heatmap.
- m: 2d ndarray of numpy (symmetric)
@lucananni93
lucananni93 / proxdet.py
Created October 31, 2017 23:03
Community detection using Networkx and Community
import numpy as np
import networkx as nx
import matplotlib
# matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
import community
def generate_random_connection_matrix(density=0.1, shape=10, loc=1, scale=2):
@lucananni93
lucananni93 / pearson_matrix.py
Created June 2, 2017 08:53
Calculate a Pearson Correlation Matrix
import numpy as np
def pearson_correlation_matrix(m1, m2):
""" This function takes as input two numpy matrices m1, m2
such that dim(m1) = (n,m) and dim(m2) = (r,m) and gives as a result
a numpy matrix such that dim(result) = (n,r) where each cell c_ij is
the result of the pearson correlation of the i-th row of m1 with the
r-th row of m2.
"""
# subtract the means