Giter Club home page Giter Club logo

pathomicfusion's Introduction

Pathomic Fusion: An Integrated Framework for Fusing Histopathology and Genomic Features for Diagnosis and Prognosis

Pathomic Fusion: An Integrated Framework for Fusing Histopathology and Genomic Features for Cancer Diagnosis and Prognosis, IEEE Transactions on Medical Imaging, 2020. [HTML] [arXiv] [Talk]
Richard J Chen, Ming Y Lu, Jingwen Wang, Drew FK Williamson, Scott J Rodig, Neal I Lindeman, Faisal Mahmood
@article{chen2020pathomic,
  title={Pathomic Fusion: An Integrated Framework for Fusing Histopathology and Genomic Features for Cancer Diagnosis and Prognosis},
  author={Chen, Richard J and Lu, Ming Y and Wang, Jingwen and Williamson, Drew FK and Rodig, Scott J and Lindeman, Neal I and Mahmood, Faisal},
  journal={IEEE Transactions on Medical Imaging},
  year={2020},
  publisher={IEEE}
}

Summary: We propose a simple and scalable method for integrating histology images and -omic data using attention gating and tensor fusion. Histopathology images can be processed using CNNs or GCNs for parameter efficiency or a combination of the the two. The setup is adaptable for integrating multiple -omic modalities with histopathology and can be used for improved diagnostic, prognostic and therapeutic response determinations.

Community / Follow-Up Work :)

GitHub Repositories / Projects

Updates

  • 05/26/2021: Updated Google Drive with all models and processed data for TCGA-GBMLGG and TCGA-KIRC. found using the following link. The data made available for TCGA-GBMLGG are the same ROIs used by Mobadersany et al.

Setup

Prerequisites

  • Linux (Tested on Ubuntu 18.04)
  • NVIDIA GPU (Tested on Nvidia GeForce RTX 2080 Tis on local workstations, and Nvidia V100s using Google Cloud)
  • CUDA + cuDNN (Tested on CUDA 10.1 and cuDNN 7.5. CPU mode and CUDA without CuDNN may work with minimal modification, but untested.)
  • torch>=1.1.0
  • torch_geometric=1.3.0

Code Base Structure

The code base structure is explained below:

  • train_cv.py: Cross-validation script for training unimodal and multimodal networks. This script will save evaluation metrics and predictions on the train + test split for each epoch on every split in checkpoints.
  • test_cv.py: Script for testing unimodal and unimodal networks on only the test split.
  • train_test.py: Contains the definitions for "train" and "test".
  • networks.py: Contains PyTorch model definitions for all unimodal and multimodal network.
  • fusion.py: Contains PyTorch model definitions for fusion.
  • data_loaders.py: Contains the PyTorch DatasetLoader definition for loading multimodal data.
  • options.py: Contains all the options for the argparser.
  • make_splits.py: Script for generating a pickle file that saves + aligns the path for multimodal data for cross-validation.
  • run_cox_baselines.py: Script for running Cox baselines.
  • utils.py: Contains definitions for collating, survival loss functions, data preprocessing, evaluation, figure plotting, etc...

The directory structure for your multimodal dataset should look similar to the following:

./
├── data
      └── PROJECT
            ├── INPUT A (e.g. Image)
                ├── image_001.png
                ├── image_002.png
                ├── ...
            ├── INPUT B (e.g. Graph)
                ├── image_001.pkl
                ├── image_002.pkl
                ├── ...
            └── INPUT C (e.g. Genomic)
                └── genomic_data.csv
└── checkpoints
        └── PROJECT
            ├── TASK X (e.g. Survival Analysis)
                ├── path
                    ├── ...
                ├── ...
            └── TASK Y (e.g. Grade Classification)
                ├── path
                    ├── ...
                ├── ...

Depending on which modalities you are interested in combining, you must: (1) write your own function for aligning multimodal data in make_splits.py, (2) create your DatasetLoader in data_loaders.py, (3) modify the options.py for your data and task. Models will be saved to the checkpoints directory, with each model for each task saved in its own directory. At the moment, the only supervised learning tasks implemented are survival outcome prediction and grade classification.

Training and Evaluation

Here are example commands for training unimodal + multimodal networks.

Survival Model for Input A

Example shown below for training a survival model for mode A and saving the model checkpoints + predictions at the end of each split. In this example, we would create a folder called "CNN_A" in "./checkpoints/example/" for all the models in cross-validation. It assumes that "A" is defined as a mode in dataset_loaders.py for handling modality-specific data-preprocessing steps (random crop + flip + jittering for images), and that there is a network defined for input A in networks.py. "surv" is already defined as a task for training networks for survival analysis in options.py, networks.py, train_test.py, train_cv.py.

python train_cv.py --exp_name surv --dataroot ./data/example/ --checkpoints_dir ./checkpoints/example/ --task surv --mode A --model_name CNN_A --niter 0 --niter_decay 50 --batch_size 64 --reg_type none --init_type max --lr 0.002 --weight_decay 4e-4 --gpu_ids 0

To obtain test predictions on only the test splits in your cross-validation, you can replace "train_cv" with "test_cv".

python test_cv.py --exp_name surv --dataroot ./data/example/ --checkpoints_dir ./checkpoints/example/ --task surv --mode input_A --model input_A_CNN --niter 0 --niter_decay 50 --batch_size 64 --reg_type none --init_type max --lr 0.002 --weight_decay 4e-4 --gpu_ids 0

Grade Classification Model for Input A + B

Example shown below for training a grade classification model for fusing modes A and B. Similar to the previous example, we would create a folder called "Fusion_AB" in "./checkpoints/example/" for all the models in cross-validation. It assumes that "AB" is defined as a mode in dataset_loaders.py for handling multiple inputs A and B at the same time. "grad" is already defined as a task for training networks for grade classification in options.py, networks.py, train_test.py, train_cv.py.

python train_cv.py --exp_name surv --dataroot ./data/example/ --checkpoints_dir ./checkpoints/example/ --task grad --mode AB --model_name Fusion_AB --niter 0 --niter_decay 50 --batch_size 64 --reg_type none --init_type max --lr 0.002 --weight_decay 4e-4 --gpu_ids 0

Reproducibility

To reporduce the results in our paper and for exact data preprocessing, implementation, and experimental details please follow the instructions here: ./data/TCGA_GBMLGG/. Processed data and trained models can be downloaded here.

Issues

  • Please open new threads or report issues directly (for urgent blockers) to [email protected].
  • Immediate response to minor issues may not be available.

Licenses, Usages, and Acknowledgements

  • This project is licensed under the GNU GPLv3 License - see the LICENSE.md file for details. A provisional patent on this work has been filed by the Brigham and Women's Hospital.
  • This code is inspired by SALMON and SCNN. Code base structure was inspired by pytorch-CycleGAN-and-pix2pix.
  • Subsidized computing resources for this project were provided by Nvidia and Google Cloud.
  • If you find our work useful in your research, please consider citing our paper at:
@article{chen2020pathomic,
  title={Pathomic Fusion: An Integrated Framework for Fusing Histopathology and Genomic Features for Cancer Diagnosis and Prognosis},
  author={Chen, Richard J and Lu, Ming Y and Wang, Jingwen and Williamson, Drew FK and Rodig, Scott J and Lindeman, Neal I and Mahmood, Faisal},
  journal={IEEE Transactions on Medical Imaging},
  year={2020},
  publisher={IEEE}
}

© Mahmood Lab - This code is made available under the GPLv3 License and is available for non-commercial academic purposes.

pathomicfusion's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pathomicfusion's Issues

Regard reproducing the GBMLGG survival prediction

Hello,

Thanks for sharing the code and data. I have three questions related to the survival prediction with GBMLGG dataset.

  1. I used the released models and data splits to make survival prediction and I got average cindex_test 0.8078 for Pathomic Fusion model and 0.7104 for the trained GCN model, which are lower than the value reported in the paper (0.826 and 0.746). Do you perhaps know why?

These are the environment and command lines I used to reproduce the result:

torch==1.9.0
torch-cluster==1.5.9
torch-geometric==1.3.0
torch-scatter==2.0.7
torch-sparse==0.6.10

PathomicFusion: test_cv.py --exp_name surv_15_rnaseq --task surv --mode pathgraphomic --model_name pathgraphomic_fusion --niter 10 --niter_decay 20 --lr 0.0001 --beta1 0.5 --fusion_type pofusion_A --mmhid 64 --use_bilinear 1 --use_vgg_features 1 --gpu_ids 0 --omic_gate 0 --grph_scale 2 --use_rnaseq 1 --input_size_omic 320 --reg_type none

GCN: test_cv.py --exp_name surv_15_rnaseq_dbcheck --task surv --mode graph --model_name graph --niter 0 --niter_decay 50 --lr 0.002 --init_type max --reg_type none --lambda_reg 0 -use_vgg_features 1 --gpu_ids 0

  1. According to the #4, when doing the evaluation, mean accuracy of the 9 patches is used for each sample (1024 x 1024). Maybe I missed something, but I did not find where is the code to average the 9 patches.

  2. When I ran the command line: --exp_name surv_15_rnaseq --task surv --mode path --model_name path --niter 0 --niter_decay 50 --batch_size 8 --lr 0.0005 --reg_type none --lambda_reg 0 --gpu_ids 0 --use_vgg_features 1 to test the trained CNN model, I got the following error: RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 3, 3, 3], but got 2-dimensional input of size [8, 32] instead. I think there is a conflict between the input features (batchsize * 32) and the model (require 512 x 512 patches as inputs), so I should change either code or input features to let it run, right?

Thanks for your help!

The generation of pkl files

How did you generate the pkl files in the splits folder and could you provide the source code? Looking forward to your answer, thank you!

About the CIndex

Is there an error in this function? The elif hazards[j] < hazards[i]: concord += 0.5 should be change to elif hazards[j] == hazards[i]: concord += 0.5. Right ?

def CIndex(hazards, labels, survtime_all):
    concord = 0.
    total = 0.
    N_test = labels.shape[0]
    for i in range(N_test):
        if labels[i] == 1:
            for j in range(N_test):
                if survtime_all[j] > survtime_all[i]:
                    total += 1
                    if hazards[j] < hazards[i]: concord += 1
                    elif hazards[j] < hazards[i]: concord += 0.5

    return(concord/total)

Can't find some .pt files about graph features

Hello,
I think that I have found a problem. When I downloaded data from GoogleDrive and tried to train GCN model, I was reminded that there is no folder named all_st_patches_512_cpc in data/TCGA_GBMLGG.

Reproducibility of the GBMLGG results

Hi Richard,

Thank you for sharing the codes and data. I am very interested in your work. I have some concerns regarding the paper and the codes.

  1. In your experiments for the pathomic fusion, the histology CNN was frozen and the SNN branch was finetuned. I am curious about why you choose to freeze the CNN branch. Have you ever tried to finetune the two branches together? Or training the two branches simultaneously?
  2. In the arxiv version and the TMI version, the cindex for the histology CNN is different (0.750 vs. 0.792). Are there any difference between the settings or evaluation metrics of these two versions?
  3. In your TMI paper, you said the implementation details and some results are provided in the appendix. However, I cannot find the appendix. Could you give a link for the appendix?
  4. In your paper, there is a sentence "For cancer grade classification, we did not use mRNAseq expression due to missing data, lack of paired training examples, and because grade is solely determined from histopathologic appearance". If I understand correctly, it means the histological grading task is only related to the histology images rather than the omics data, so why would the pathomic fusion lead to performance gains on this task?

Looking forward to your reply. Thanks a lot for your time and attention.

Best,
Xiaohan

How does the loss function for grade task work (CNN-only)?

Hi, Richard. Your code has inspired me greatly:)

I'm not sure how you trained the vgg_19_bn to classify the grade; as I can see in your customised CNN, the output nueoron is one (with a probability ranging from -3 to 3); correct me if I'm wrong. However, in the CSV file, the grade has three labels: [0,1,2].
So, as far as I understand, the cnn model's output shape will be = [batch size,C), which is a one probability in this code.

For instance in case the batch size =2:

model=vgg()
output = model(image)
output_size = torch.Size([2, 1])
output_values = [[0.09075058],[0.10227629]]

Though, this code snippet confuses me

python train_cv.py  --exp_name grad_15 --task grad --mode path --model_name path --niter 0 --niter_decay 50 --batch_size 8 --lr 0.0005 --reg_type none --lambda_reg 0 --act LSM **--label_dim 3** --gpu_ids 0

If the label dim = 3, how does the loss function work?

loss nll = F.nll loss(pred, grade) In this case, pred and grade have different shapes.

Is there anything I'm missing or don't understand?

Thanks in advance,
Omnia

TypeError: scatter_mean() takes from 2 to 5 positional arguments but 6 were given

Hi @Richarizardd
I was trying to train GCN model but facing
TypeError: scatter_mean() takes from 2 to 5 positional arguments but 6 were given

while trying to run the following command.
python train_cv.py --exp_name surv_15_rnaseq --task surv --mode graph --model_name graph --niter 0 --niter_decay 50 --lr 0.002 --init_type max --reg_type none --lambda_reg 0 -use_vgg_features 1 --gpu_ids 0

Installation :
torch-cluster-1.6.1
torch-geometric-1.3.0
torch-scatter-2.1.1
torch-sparse-0.6.17

Can you please suggest.

Availability of Dataset

I have gone through Pathomic Fusion Paper and the code as well. I wanted to know if you have made the whole dataset public. At the moment I am only able to access the processed data that is in the form of 15 Folds.

Regard reproducing the GBMLGG grade calssification

Hi

Thanks for sharing the dataset and codes.

I am trying to use a simple CNN classifier to classify the grade of the GBMLGG dataset into 3 classes (2,3,4)

I am using the same split of training and testing the pathomic paper used. However, my training acc is very high 97~ 98% but validation is relatively low: 72% , same for train loss, and validation loss!

My backbone network is VGG_bn.

Is there something wrong I am doing it? Can I use the grade of the tumour as a label for the patches and classify them based on that? or that's not possible?

Thanks

CPC training

Hi @Richarizardd

Thanks for sharing the code of this interesting study. I was wondering how the CPC model is trained (pretrained or online training, data). Also, is there a file in the repository that can be used for training the CPC model?

Thanks,

About the pkl files

Do you use files from other repos to generate pkl files? If yes, please tell me how to produce the pkl files. Thx.

A question about the GCN features in the pathgraphomic mode

Thanks a lot for such an amazing work!

I have a question about running the code in pathgraphomic mode using the released TCGA-GBM + TCGA-LGG data. I know that the CNN features are extracted from 512 x 512 image patches (each 1024 x 1024 diagnostic patch is cropped into 9 512 x 512 patches with the stride of 256), then I wonder that whether the paired GCN features from 512 x 512 image patches or the 1024 x 1024 diagnostic patch?

If they come from the 1024 x 1024 diagnostic patch, does this mean that the 9 512 * 512 patches from the same diagnostic patch share the same GCN features and the mean prediction of the 9 512 * 512 patches (along with the other two views) will be used as the prediction for the 1024 x 1024 diagnostic patch?

Thank you!

Regarding reprudicing the same result of pathomic fusion

Thanks for sharing the data and the code

I am very interested in reproducing the same result for the code of the pathomic fusion.

I do have a question regarding the GCN network.

When I ran the code for all other models ( WSI and Omics), I did not get errors related to the code, and everything seemed to work very well; however, for the GCN model, I got this error.

TypeError: init() got an unexpected keyword argument 'gnn'

which is in the SAGpooling parameters (self.pool1 = SAGPooling(nhid, ratio=pooling_ratio, gnn=GNN)#, nonlinearity=nonlinearity))

Am I missing a library?

Thank you very much for your time and effort to help
Omnia

CPC_model checkpoints missing

Hello @Richarizardd,

I was going through the notebook Graph Construction.ipynb. When I tried to execute it I saw that the checkpoint file of the CPC_model model was missing. I have tried to look into previous issues and looked at the entire repo but was not able to find the checkpoints. Therefore, if you could share or point where the checkpoints are placed then it would be really helpful.

Thanks in advance.

TypeError: scatter_mean() takes from 2 to 5 positional arguments but 6 were given

Hi @Richarizardd
Great Day!

I was trying to train GCN model but facing

TypeError: scatter_mean() takes from 2 to 5 positional arguments but 6 were given

while trying to run the following command.

python train_cv.py --exp_name surv_15_rnaseq --task surv --mode graph --model_name graph --niter 0 --niter_decay 50 --lr 0.002 --init_type max --reg_type none --lambda_reg 0 -use_vgg_features 1 --gpu_ids 0

Installation :
torch-cluster-1.6.0
torch-geometric-1.3.0
torch-scatter-2.0.9
torch-sparse-0.6.15
torch-spline-conv-1.2.1
cudatoolkit-11.3.1
pytorch-1.10.1-py3.9_cuda11.3_cudnn8.2.0

Can you please suggest.

Is the molueculare subtype feature included in the Grade classification task?

Hi , Chen.

I have a question about the grade classification task.

According to the grade data.csv file, which includes age, gender, histologic grade, and subtype data

I understood that features you used to classify the grade included the subtype, correct?

Accordingly, the features for the grade classification task are: age, gender, subtype data, and the label is the histologic grade?

Thanks,
Omnia.

Omic data normalization

Hi, I want to ask a question about the data normalization. I have noticed that the RNAseq data provided in the pickle file (e.g., gbmlgg15cv_all_st_1_0_0_rnaseq.pkl) is different from the RNAseq data provided in the txt file (mRNA_Expression_z-Scores_RNA_Seq_RSEM.txt and mRNA_Expression_Zscores_RSEM.txt).
I guess maybe the data from the txt file is raw data downloaded from cBioportal, and the data from the pickle file is generated after some kind of normalization. I have utilized the raw data for experiments, but the performance is much worse than the pickle data, thus I think the data normalization must be very important. Could the author please tell me which kind of normalization have you utilized to preprocess the omic input data? Thanks a lot!

could not find MaskCNN and resnet_custom

Hello!
I could not find the part about "MaskCNN" in the code of "from pixelcnn import MaskCNN" in /CellGraph/model.py,
also "resnet_custom" of "from resnet_custom import *" in the same py file.
where could I find them?

Thanks you very much!

Data cannot be downloaded

I am very interested in your research, I want to reproduce your results, but the data given cannot be downloaded

Validation data is same as testing data?

Hi Richard,

Thank you for sharing the codes for Pathomic Fusion.

I went through the Mobadersany et al dataset (pnas_splits.csv) and saw that each of the splits only contains the "train" and "test" labels (no "validation" labels). So I was wondering what Pathomic fusion uses as validation data.

In the train_cv.py, within the train function (line 45), there is a call to the test function (line 88) for validating the model, which seems to be the same as the call for testing the model (line 49). So I was wondering if the data used for model validation is same as the data used for testing the model. I might be mistaken but please share your thoughts.

Thank you.

KNN for Cell Graph Construction

I could not find the part in the code where a cell graph is constructed from the histology image (segmented using cGAN). I have two questions in this regard:

  1. Could you point me to the code (maybe line numbers) where edge detection using top-K nearest neighbor is performed?
  2. Is cGAN part of this code? If not, where should I store the instance mask in the file system after performing nuclei segmentation?

options.py

parser.add_argument('--use_bilinear', type=int, default=1)
parser.add_argument('--path_gate', type=int, default=1)
parser.add_argument('--grph_gate', type=int, default=1)
parser.add_argument('--omic_gate', type=int, default=1)
parser.add_argument('--path_scale', type=int, default=1)
parser.add_argument('--grph_scale', type=int, default=1)
parser.add_argument('--omic_scale', type=int, default=1)
Can you tell me the use of these parameters in the options.py file?
When I run the GCN+SNN code, I get an error using the command you gave me.
FileNotFoundError: [Errno 2] No such file or directory: './data/TCGA_GBMLGG/all_st_patches_512_cpc/TCGA-12-0616-01Z-00-DX3.b426f381-b175-4a6d-957e-2dbfed42caeb_2_256_0.pt'.
But it can run after deleting some of the above parameters in the code you gave.
Can you please answer this?

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.