Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott Warchal Swarchal

View GitHub Profile
@Swarchal
Swarchal / parse_yokogawa.py
Created Jan 17, 2020
parse metadata from yokogawa CV{7,8}000 filepaths
View parse_yokogawa.py
import os
from collections import namedtuple
from typing import NamedTuple, List
import pandas as pd
def parse_filepath(filepath: str) -> NamedTuple:
"""
0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20
T|0|0|0|1|F|0|0|6|L|0 |1 |A |0 |4 |Z |0 |1 |C |0 |2
------------------------------------------------------
@Swarchal
Swarchal / czi2tif.py
Created Nov 13, 2019
Convert multi-{channel, z} czi files to simple single tif
View czi2tif.py
import os
import czifile
import skimage.io
import numpy as np
def read_czi(fname):
"""shape: [1, 1, channel, z, x, y, 1]"""
return fname, czifile.imread(fname)
@Swarchal
Swarchal / welford.py
Created Sep 12, 2019
Welford's online/incremental variance calculation
View welford.py
class OnlineVariance:
"""Welfords online variance calculation"""
def __init__(self, arr):
self.arr = arr # np.array
self.mean = arr
self.count = 1
self._M2 = 0
def update(self, arr):
View gist:8b778920da10a5a1dd6845d1661218ff
Image_Metadata_PlateID Image_Metadata_CPD_WELL_POSITION Image_Metadata_ASSAY_WELL_ROLE Image_Metadata_BROAD_ID Image_Metadata_CPD_MMOL_CONC
24277 A01 compound BRD-K18250272-003-03-7 3.02251611288227196974775712680585514568
24277 A02 compound BRD-K18316707-001-01-9 5
24277 A03 compound BRD-K18438502-001-02-6 5
24277 A04 compound BRD-K18550767-001-02-8 5
24277 A05 compound BRD-K18574842-323-03-3 2.1954869000456068493180626771633583428
24277 A06 compound BRD-K18619710-001-03-7 2.56073382027223366102019737828998599945
24277 A07 compound BRD-K18742343-001-03-2 5
24277 A08 compound BRD-K18757346-001-02-9 .5
24277 A09 compound BRD-K18779551-003-03-7 4.99999999999999999987113402061855670103
@Swarchal
Swarchal / colab_ai_fnet.py
Last active Jan 28, 2019
conda install packages on google colab notebooks
View colab_ai_fnet.py
# install anaconda 5.10
! wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
! chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
! bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p /usr/local
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')
# install conda dependencies
! conda install -y --prefix /usr/local pytorch==0.4.0 torchvision=0.1.8 -c pytorch
View data_utils.py
"""
docstring
"""
import os
import glob
import itertools
import numpy as np
import skimage.io
View Untitled12.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View test_index_error_bodge(1).ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Swarchal
Swarchal / readmap.ipynb
Created Sep 25, 2018
Adding data from a plate-map matrix
View readmap.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Swarchal
Swarchal / multi_z_factor.py
Created Aug 23, 2018
Multivariate Z-prime/factor (Kummel et al, 2010) in python
View multi_z_factor.py
import numpy as np
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
def z_factor(p, n):
numerator = 3 * (np.std(p) + np.std(n))
denominator = np.abs(np.mean(p) - np.mean(n))
return 1 - (numerator / denominator)
def multivariate_z_factor(data, labels):