Skip to content

Commit

Permalink
Merge pull request #24 from VasudhaJha/feature/export-all-files
Browse files Browse the repository at this point in the history
Feature/export all files
  • Loading branch information
VasudhaJha authored Jul 14, 2023
2 parents b2ef46f + ba295c5 commit f6950bf
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 26 deletions.
59 changes: 47 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Genomap is an entropy-based cartography strategy to contrive the high dimensional gene expression data into a configured image format with explicit integration of the genomic interactions. This unique cartography casts the gene-gene interactions into a spatial configuration and enables us to extract the deep genomic interaction features and discover underlying discriminative patterns of the data. For a wide variety of applications (cell clustering and recognition, gene signature extraction, single-cell data integration, cellular trajectory analysis, dimensionality reduction, and visualization), genomap drastically improves the accuracy of data analyses as compared to state-of-the-art techniques.

# Required packages
## Required packages

scipy, scikit-learn, pot, numpy

If you face any issues with packages, please check the environment section of our Code-Ocean capsule (https://doi.org/10.24433/CO.0640398.v1), where you can check the package versions.

# How to use genomap
## How to use genomap

The easiest way to start with genomap is to install it from pypi using

Expand All @@ -17,25 +17,22 @@ pip install genomap
```
The data should be in cell (row) x gene (column) format. Genomap construction needs only one parameter: the size of the genomap (row and column number). The row and column number can be any number starting from 1. You can create square or rectangular genomaps. The number of genes in your dataset should be less than or equal to the number of pixels in the genomap. Genomap construction is very fast and you should get the genomaps within a few seconds.

# Sample data
## Sample data

To run the example code below, you will need to download the required data file. You can download it from [here](https://drive.google.com/file/d/1kkbI9_6zD80Jr5OhMkGlcdMOeWcRfz7b/view?usp=drive_link).
To run the example codes below, you will need to download data files from [here](https://drive.google.com/drive/folders/1xq3bBgVP0NCMD7bGTXit0qRkL8fbutZ6?usp=drive_link).

# Example code
## Example codes

### Example 1 - Construct a genomap

```python
import pandas as pd # Please install pandas and matplotlib before you run this example

import matplotlib.pyplot as plt

import scipy

import genomap as gp

data = pd.read_csv('TM_data.csv', header=None, delim_whitespace=False)

colNum=31 # Column number of genomap

rowNum=31 # Row number of genomap

dataNorm=scipy.stats.zscore(data,axis=0,ddof=1) # Normalization of the data
Expand All @@ -45,12 +42,50 @@ genoMaps=gp.construct_genomap(dataNorm,rowNum,colNum) # Construction of genomaps
findI=genoMaps[0,:,:,:]

plt.figure(1) # Plot the first genomap

plt.imshow(findI, origin = 'lower', extent = [0, 10, 0, 10], aspect = 1)

plt.title('Genomap of a cell from TM dataset')
```

### Example 2 - Try out genoVis, genoTraj and genoMOI

```python
import scipy.io as sio
import numpy as np
from genomap.genoVis import compute_genoVis
from genomap.genoTraj import compute_genoTraj
from genomap.genoMOI import compute_genoMOI

dx = sio.loadmat('reducedData_divseq.mat')
data=dx['X']
gt_data = sio.loadmat('GT_divseq.mat')
y = np.squeeze(gt_data['GT'])
n_clusters = len(np.unique(y))


resVis=compute_genoVis(data,n_clusters=n_clusters, colNum=33,rowNum=33)

dx = sio.loadmat('organoidData.mat')
data=dx['X3']
gt_data = sio.loadmat('cellsPsudo.mat')
Y_time = np.squeeze(gt_data['newGT'])


outGenoTraj=compute_genoTraj(data)

dx = sio.loadmat('MOIdata/dataBaronX.mat')
data=dx['dataBaron']
dx = sio.loadmat('MOIdata/dataMuraroX.mat')
data2=dx['dataMuraro']
dx = sio.loadmat('MOIdata/dataScapleX.mat')
data3=dx['dataScaple']
dx = sio.loadmat('MOIdata/dataWangX.mat')
data4=dx['dataWang']
dx = sio.loadmat('MOIdata/dataXinX.mat')
data5=dx['dataXin']

resVis=compute_genoMOI(data, data2, data3, data4, data5, colNum=44, rowNum=44)
```

# Citation

If you use the genomap code, please cite our Nature Communications paper: https://www.nature.com/articles/s41467-023-36383-6
Expand Down
6 changes: 3 additions & 3 deletions genomap/genoMOI/genoMOI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"""

from tensorflow.keras.optimizers import Adam
from genomap.ConvIDEC import ConvIDEC
from utils.ConvIDEC import ConvIDEC
# from ConvIDEC import ConvIDEC
from sklearn.feature_selection import VarianceThreshold
from genomap.genomap import construct_genomap
import umap
from genomap.gTraj_utils import nearest_divisible_by_four
from utils.gTraj_utils import nearest_divisible_by_four
# from gTraj_utils import nearest_divisible_by_four
from genomap.utils_MOI import *
from utils.utils_MOI import *
# from utils_MOI import *

def compute_genoMOI(*arrays,n_clusters=None, colNum, rowNum):
Expand Down
6 changes: 3 additions & 3 deletions genomap/genoTraj/genoTraj.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import phate
import numpy as np
from genomap.class_discriminative_opt import ClassDiscriminative_OPT
from utils.class_discriminative_opt import ClassDiscriminative_OPT
import scipy
from genomap.gTraj_utils import compute_cluster_distances, nearest_divisible_by_four
from utils.gTraj_utils import compute_cluster_distances, nearest_divisible_by_four
from tensorflow.keras.optimizers import Adam
from genomap.ConvIDEC import ConvIDEC
from utils.ConvIDEC import ConvIDEC
from sklearn.feature_selection import VarianceThreshold
from genomap.genomap import construct_genomap
# from gTraj_utils import nearest_divisible_by_four
Expand Down
4 changes: 2 additions & 2 deletions genomap/genoVis/genoVis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"""

from tensorflow.keras.optimizers import Adam
from genomap.ConvIDEC import ConvIDEC
from utils.ConvIDEC import ConvIDEC
from sklearn.feature_selection import VarianceThreshold
from genomap.genomap import construct_genomap
import umap
# from gTraj_utils import nearest_divisible_by_four
from genomap.gTraj_utils import nearest_divisible_by_four
from utils.gTraj_utils import nearest_divisible_by_four
import scanpy as sc
import numpy as np
import pandas as pd
Expand Down
3 changes: 1 addition & 2 deletions genomap/ConvDEC.py → genomap/utils/ConvDEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from tensorflow.keras.layers import Conv2D, Conv2DTranspose, Dense, Flatten, Reshape, InputLayer
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from FcDEC import FcDEC, ClusteringLayer

from .FcDEC import FcDEC, ClusteringLayer

def CAE(input_shape=(28, 28, 1), filters=[32, 64, 128, 10]):
model = Sequential()
Expand Down
2 changes: 1 addition & 1 deletion genomap/ConvIDEC.py → genomap/utils/ConvIDEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

from tensorflow.keras.models import Model
from ConvDEC import ConvDEC
from .ConvDEC import ConvDEC


class ConvIDEC(ConvDEC):
Expand Down
2 changes: 1 addition & 1 deletion genomap/FcDEC.py → genomap/utils/FcDEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from tensorflow.keras.initializers import VarianceScaling
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from sklearn.cluster import KMeans
import metrics
from .metrics import *


def autoencoder(dims, act='relu'):
Expand Down
2 changes: 1 addition & 1 deletion genomap/FcIDEC.py → genomap/utils/FcIDEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""

from tensorflow.keras.models import Model
from FcDEC import FcDEC
from .FcDEC import FcDEC


class FcIDEC(FcDEC):
Expand Down
9 changes: 9 additions & 0 deletions genomap/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .class_discriminative_opt import *
from .ConvDEC import *
from .ConvIDEC import *
from .FcDEC import *
from .FcIDEC import *
from .group_centroid_opt import *
from .gTraj_utils import *
from .metrics import *
from .utils_MOI import *
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="genomap",
version="1.0.5",
version="1.0.6",
author="Md Tauhidul Islam",
author_email="[email protected]",
description="Genomap converts tabular gene expression data into spatially meaningful images.",
Expand Down

0 comments on commit f6950bf

Please sign in to comment.