Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Getting started
|
| 2 |
+
|
| 3 |
+
# Environment setup
|
| 4 |
+
Create a conda environment using the following command:
|
| 5 |
+
```
|
| 6 |
+
conda env create -f environment.yml
|
| 7 |
+
conda activate plt
|
| 8 |
+
```
|
| 9 |
+
You might need to adjust the CUDA versions.
|
| 10 |
+
|
| 11 |
+
# Evaluate your own images
|
| 12 |
+
|
| 13 |
+
We have uploaded an example folder in Hugging Face to ease playing around with our models and as a reference for how to format the data. But if you have your own images that wou would like to test, you can also use them!
|
| 14 |
+
You just need to have a folder with the TIFF files and a parquet index file.
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
hf download anasanchezf/plate_effects example.tar.gz --type=dataset --local-dir="."
|
| 18 |
+
tar -xzf example.tar.gz
|
| 19 |
+
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
import pandas as pd
|
| 25 |
+
from sklearn.metrics import accuracy_score
|
| 26 |
+
from sklearn.preprocessing import LabelEncoder
|
| 27 |
+
from plt.model.pretrained import PreTrainedARMBN
|
| 28 |
+
|
| 29 |
+
# COMPOUND ENCODING
|
| 30 |
+
# 'JCP2022_012818': 0 TC-S-7004
|
| 31 |
+
# 'JCP2022_025848': 1 dexamethasone
|
| 32 |
+
# 'JCP2022_035095': 2 LY2109761
|
| 33 |
+
# 'JCP2022_037716': 3 AMG900
|
| 34 |
+
# 'JCP2022_046054': 4 FK-866
|
| 35 |
+
# 'JCP2022_050797': 5 quinidine
|
| 36 |
+
# 'JCP2022_064022': 6 NVS-PAK1-1
|
| 37 |
+
# 'JCP2022_085227': 7 aloxistatin
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
perturbed = pd.read_parquet("example/plate_index.pq")
|
| 41 |
+
controls = pd.read_parquet("example/plate_index_controls.pq")
|
| 42 |
+
|
| 43 |
+
perturbed_and_controls = pd.concat([perturbed, controls])
|
| 44 |
+
|
| 45 |
+
model = PreTrainedCSARMBN()
|
| 46 |
+
|
| 47 |
+
model.adapt(perturbed_and_controls)
|
| 48 |
+
probs, uncertainty = model.predict(perturbed)
|
| 49 |
+
|
| 50 |
+
label_encoder = LabelEncoder()
|
| 51 |
+
labels = label_encoder.fit_transform(perturbed["Metadata_JCP2022"])
|
| 52 |
+
accuracy_score(labels, probs.argmax(dim=1).cpu())
|
| 53 |
+
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
# Train your own adaptable models
|
| 57 |
+
|
| 58 |
+
## Download the data
|
| 59 |
+
``` bash
|
| 60 |
+
preprocess/images/01-download_indices.sh
|
| 61 |
+
preprocess/images/02-download_metadata.sh
|
| 62 |
+
python preprocess/images/03-create_indices.py
|
| 63 |
+
python preprocess/images/04-download_images_aws.py
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## Run CS-ARM-BN
|
| 67 |
+
``` bash
|
| 68 |
+
scripts/run_cs_arm_bn.sh
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## Additional dependencies
|
| 72 |
+
To use the Channel Agnostic Masked Autoencoder baseline you will have to export or install the package as follows.
|
| 73 |
+
|
| 74 |
+
``` bash
|
| 75 |
+
git clone https://github.com/recursionpharma/maes_microscopy.git
|
| 76 |
+
git clone https://huggingface.co/recursionpharma/OpenPhenom
|
| 77 |
+
export PYTHONPATH="${PYTHONPATH}:${PWD}/maes_microscopy"
|
| 78 |
+
```
|