This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import sys | |
from random import choice | |
from string import ascii_letters | |
from time import sleep | |
charset = ascii_letters + '!@#$%^&*()[]<>./m::~`|\\"' | |
def scroll_text(text: str, delay: float = 0.01, n_chars: int = 5) -> None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
def find_correlation(df, thresh=0.9): | |
""" | |
Given a numeric pd.DataFrame, this will find highly correlated features, | |
and return a list of features to remove | |
params: | |
- df : pd.DataFrame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
def find_correlation(data, threshold=0.9, remove_negative=False): | |
""" | |
Given a numeric pd.DataFrame, this will find highly correlated features, | |
and return a list of features to remove. | |
Parameters | |
----------- | |
data : pandas DataFrame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tempfile | |
from collections import defaultdict | |
import string | |
import htsomeropy | |
import pandas as pd | |
from tqdm import tqdm | |
import cellprofiler_core.preferences as cpprefs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(reshape2) | |
df_expression <- read.csv("expression.csv") | |
df_molten <- melt(df_expression) | |
ggplot(data = df_molten, | |
aes(x = variable, y = MouseID, fill = value)) + | |
geom_raster() + | |
xlab("Protein") + | |
scale_fill_distiller(palette = "RdYlBu", trans = "log10") + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
NewerOlder