Code Monkey home page Code Monkey logo

egn's Introduction

Dependency

  • python 3.9.4
  • pytorch_lightning 1.5.7
  • numpy 1.23.3
  • Pandas 1.5.2
  • tifffile 2021.7.2
  • Pillow 9.3.0
  • scanpy 1.9.1
  • torch 1.9.1+cu111
  • torchvision 0.10.1+cu111
  • einops 0.3.2

Dataset

  • Obtain 10xgenomics dataset.

  • We use the slide images blow, and please structure the data files as follows.

└───10xgenomics
    └───1.0.0
    │   │ V1_Breast_Cancer_Block_A_Section_1
    |   | V1_Breast_Cancer_Block_A_Section_2
    │  
    │
    └───1.1.0
    |   │ V1_Breast_Cancer_Block_A_Section_1
    |   | V1_Breast_Cancer_Block_A_Section_2
    |   
    |
    └───1.2.0
    |   │ Parent_Visium_Human_BreastCancer
    |   | Targeted_Visium_Human_BreastCancer_Immunology

Train EGN

  • Change system directory
cd v1
  • Build index for exemplar retrival
for fold in {0..2}
do
python3 build_exemplar.py --index_dir index --save_dir exemplar --TORCH_HOME PLEASE Fill --data PLEASE Fill --fold $fold #Set torch home and data path properly, e.g., 10xgenomics 

done
  • Gene expression prediction
for fold in {0..2}
do
	python3 main.py --num_nodes 1 --gpus 1 --epoch 50 --batch 32 --workers 6 --size 256 --data PLEAE FILL --fold $fold \
		--lr 5e-4 --weight_decay 1e-4 --dim 1024 --heads 16 --mlp_dim 4096 --depth 8 --bhead 8 --bdim 64  \
		--bfre 2 --player 2 --linear_projection True --index_path exemplar/index \
		        --emb_path exemplar --mdim 2048 --numk 6   #Set data path properly 
done  

Dependency

  • python 3.9.4
  • pytorch_lightning 1.5.7
  • numpy 1.23.3
  • Pandas 1.5.2
  • tifffile 2021.7.2
  • Pillow 9.3.0
  • scanpy 1.9.1
  • torch 1.9.1+cu111
  • torchvision 0.10.1+cu111
  • torch-geometric 2.1.0.post1

Train EGGN

  • Change system directory
cd v2
  • Build index for exemplar retrival
for fold in {0..2}
do
python3 build_exemplar.py --index_dir index --save_dir exemplar --TORCH_HOME PLEASE Fill --data PLEASE Fill --fold $fold #Set torch home and data path properly 

done
  • Build graphs
python3 generate_graph.py --savename 10xpro --size 256 --numk 6 --mdim 512 --index_path index --emb_path exemplar --data PLEASE Fill #Set data path properly 
  • Gene expression prediction
for fold in {0..2}
do
python3 main.py  --gpus 1 --epoch 300 --fold $fold  --lr 5e-4 --weight_decay 1e-4 --mdim 512 --numk 6  --graph_path 10xpro --num_layers 4

done

Code for Related Work

Notice

  • This is a minimal exemple to train EGN and EGGN on the 10xgenomics dataset. If you want to use StyleGAN-based exemplar retrival, please refer to S2FGAN.
  • There are some typos on the paper. We have updated the pdf. Please find it here.
  • Please find the EGGN here.
  • We have refactored the code, and potential error may exist. If you have question related to our work, please drop me an email.

Citation

If you find EGN useful in your research work, please consider citing:

@inproceedings{egn2023,
  author    = {Yan Yang and
               Md. Zakir Hossain and
               Eric A. Stone and
               Shafin Rahman},
  title     = {Exemplar Guided Deep Neural Network for Spatial Transcriptomics Analysis
               of Gene Expression Prediction},
  booktitle = {{IEEE/CVF} Winter Conference on Applications of Computer Vision, {WACV}
               2023, Waikoloa, HI, USA, January 2-7, 2023},
  pages     = {5028--5037},
  publisher = {{IEEE}},
  year      = {2023},
  url       = {https://doi.org/10.1109/WACV56688.2023.00501},
  doi       = {10.1109/WACV56688.2023.00501},
}

@article{eggn2023,
title = {Spatial transcriptomics analysis of gene expression prediction using exemplar guided graph neural network},
journal = {Pattern Recognition},
volume = {145},
pages = {109966},
year = {2024},
issn = {0031-3203},
doi = {https://doi.org/10.1016/j.patcog.2023.109966},
url = {https://www.sciencedirect.com/science/article/pii/S0031320323006647},
author = {Yan Yang and Md Zakir Hossain and Eric Stone and Shafin Rahman},
keywords = {Spatial transcriptomics, Gene expression prediction, Deep learning, Graph convolution, Tissue slide image},
}

egn's People

Contributors

yan98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

egn's Issues

Problem when applying convolutions on model.py

Hello Yan! First of all, thank you for your paper and your code, they are both very thorough and neatly done, congratulations on your work! I am a student in a Computer Science Masters program, and as part of a coursework assignment I have been trying to reproduce your results. However, I have encoutered a few obstacles, for example the fact that I was not able to install the packages on the versions you specified. I am trying to adapt the code to comply with the versions I am using, but there is one specific problem I haven't been able to fix:

I believe there is a bug caused by model.py, on the function forward, during the convolutional layers step:

def forward(self, x_dict, edge_index_dict):
        
        x_dict["example"]  = self.post_transform(self.pretransform_exp(x_dict["example"]))
        x_dict['window'] = self.post_transform(self.pretransform_win(x_dict['window']))
        x_dict["example_y"] = self.pretransform_ey(x_dict["example"][:,-250:])
        
        for conv in self.convs:
            x_dict = conv(x_dict, edge_index_dict)
            x_dict = {key: self.leaklyrelu(x) for key, x in x_dict.items()}
        return self.lin(self.pool(x_dict, edge_index_dict))

From what I have tested, during the convolution process the key 'example' disappears from x_dict, and on my understanding this induces an error in csra.py, this one specifically:

ERROR
On csra.py, line 19, in forward:

src = x_dict['example']
KeyError: 'example'

I am pretty sure the key 'example' only disappears from x_dict after these convolutions, and then it induces this error. Do you have any insights that could help me fix this error? Thank you in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.