Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View afrendeiro's full-sized avatar

André F. Rendeiro afrendeiro

View GitHub Profile
from pathlib import Path
import tifffile
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
from stardist.models import StarDist2D
from csbdeep.utils import normalize
_dir = Path("HumanLiverH35")
files = list(
@afrendeiro
afrendeiro / markers_to_cell_type_labels.yaml
Last active May 9, 2022 14:39
Annotation of marker epitopes for various cell types
# This annotation of cell type markers is tailored for surface proteins
# normally profilid with multiplexed imaging (IMC, CODEX).
# It is a simple reference for myself and may be more detailed in some parts than others.
# This reference is hierarchical.
# This annotation is generally pan-tissue.
# Author: Andre Rendeiro
# License: CC BY-SA 2.0
cell_types:
structural:
@afrendeiro
afrendeiro / mask_to_labelme_json.py
Created July 7, 2021 17:23
Convert a labeled image mask to a JSON file compatible with labelme. Useful to export predictions and then fine tune by hand with labelme.
import pathlib
import numpy as np
def mask_to_labelme(
labeled_image: np.ndarray,
filename: pathlib.Path,
overwrite: bool = False,
simplify: bool = True,
simplification_threshold: float = 5.0,
import string
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# generate some data
n_groups = 4
n_per_group = 5
@afrendeiro
afrendeiro / interactive_volume_viewer.py
Created May 21, 2021 16:58
An example program to display a volumetric image from the command line using matplotlib
#!/usr/bin/env python
"""
An example program to display a volumetric image from the command line.
"""
import sys
import typing as tp
from urlpath import URL
from functools import partial
@afrendeiro
afrendeiro / upload_zipfiles_to_box.py
Created February 1, 2021 17:19
Upload content of zipfiles to box.com programmatically
#!/usr/bin/env python
"""
Upload images inside zip files to box.com.
"""
import sys, time, webbrowser, json, zipfile, tempfile, urllib3
from argparse import ArgumentParser
from pathlib import Path
from typing import Dict, List, Generator
@afrendeiro
afrendeiro / dog_ex.py
Created December 29, 2020 16:30 — forked from leonidk/dog_ex.py
difference of gaussians example in python
from skimage import data, feature, color, filters, img_as_float
from matplotlib import pyplot as plt
original_image = img_as_float(data.chelsea())
img = color.rgb2gray(original_image)
k = 1.6
plt.subplot(2,3,1)
@afrendeiro
afrendeiro / nih_grant_link_eracommons.md
Last active December 28, 2020 20:30
Linking NIH grant number to publications in NCBI/eRA Commons
@afrendeiro
afrendeiro / series_matrix2csv.py
Created December 10, 2020 16:49
Get a GEO series matrix file describing an experiment and parse it into project level and sample level data.
#!/usr/bin/env python
"""
Get a GEO series matrix file describing an experiment and
parse it into project level and sample level data.
"""
import os
from typing import Tuple, Union
import tempfile
@afrendeiro
afrendeiro / get_gene_set_libraries.py
Last active March 4, 2024 13:43
Download gene set libraries from Enrichr in GMT format for ssGSEA - done in parallel with async
from pathlib import Path
import parmap
import requests
def update(gsll):
return [g for g in gsll if not (output_dir / (g + ".gmt")).exists()]