Giter Club home page Giter Club logo

alignscape's Introduction

AlignScape

The AlignScape package takes an MSA as input and uses a self-organizing map to compute the sequence landscape of the input data.

GitFigure

AlignScape can be utilized as a Jupyter Notebook on their local machines or within a Google Colaboratory Notebook, supporting both CPUs and GPUs.

AlignScape Google Colab

AlignScape locally with a Singularity/Apptainer image

Download the image alignscape.sif

The image can be downloaded using the following link on Zenodo platform:

https://zenodo.org/records/10417520

Using the Singularity image

The image can be used as follows:

singularity run --nv alignscape.sif align_scape -h

If you don't have a GPU on your computer, remove the --nv option.

To run AlignScape on a alignment in fasta format, simply run:

singularity run --nv alignscape.sif align_scape -a alignment.fasta --nepochs 100

PLEASE NOTE: Singularity mounts only a part of your file system. To ensure that your fasta file is accessible within the singularity image, you should place it in your home directory or in your home directory hierarchy. This should guarantee its availability for use.

Plotting the U-matrix

singularity run --nv alignscape.sif python3 /usr/local/lib/python3.11/dist-packages/alignscape/plot_umat.py -s somfile.pickle -o outname

AlignScape locally within a conda environment

Create a conda enviroment and install AlignScape on it:

conda create -n alignscape python=3.12
ENV_PATH=$(conda info --envs | grep 'alignscape' | awk '{print $NF}')
cd $ENV_PATH/lib/python3.12/site-packages/
git clone https://github.com/bougui505/alignscape
cd alignscape
git clone https://github.com/bougui505/quicksom

A list of the needed dependencies can be found at apptainer/alignscape.def

Using AlignScape in the conda environment:

conda activate alignscape

To run AlignScape on a alignment in fasta format, simply run

python -m alignscape.align_scape -a alignment.fasta

Plotting the U-matrix

python -m alignscape.plot_umat -s somfile.pickle -o outname

Test

To check AlignScape local installation:

./test_som.sh

Reference

Please cite ...

alignscape's People

Contributors

ifilella avatar vincentx15 avatar pellarin avatar

Stargazers

Peter Clarke avatar Christian Rohde avatar xvazquezc avatar  avatar

Watchers

James Cloos avatar  avatar Guillaume Bouvier avatar  avatar

Forkers

pellarin ifilella

alignscape's Issues

limit on MSA length?

hi i am getting following error. is there some limit on protein length?

n_input: 985
opening seq.aln
cuda:0
batch_size: 10
sigma: 22.5
alpha: 0.5
seq.aln opened with object id 138143134556656 for worker 0
seq.aln opened with object id 138143134557008 for worker 1

OutOfMemoryError Traceback (most recent call last)
in <cell line: 10>()
9 test_aln = '/content/alignscape/data/Human_kinome/human_kinome_noPLK5.aln'
10 if np.genfromtxt('seq.aln').size > 0:
---> 11 align_scape.main(ali="seq.aln", batch_size=10,
12 outname="som", somside=somside, nepochs=nepochs,
13 scheduler="exp", alpha=alpha, sigma= sigma)

2 frames
/content/alignscape/quicksom/som.py in call(self, x, learning_rate_op)
317 expanded_x = x.expand(-1, self.grid_size, -1)
318 expanded_weights = self.centroids.unsqueeze(0).expand((batch_size, -1, -1))
--> 319 delta = expanded_x - expanded_weights
320 delta = torch.mul(learning_rate_multiplier.reshape(*learning_rate_multiplier.size(), 1).expand_as(delta), delta)
321

OutOfMemoryError: CUDA out of memory. Tried to allocate 24.74 GiB (GPU 0; 14.75 GiB total capacity; 5.45 GiB already allocated; 9.14 GiB free; 5.48 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

conda installation

with the current conda installation described in the readme, it is not possible to use alignscape as a python module, as it is not recognized. Any workaround?

Some Errors

Hi there,

I have 3 problems:

(1) I have some errors with python3 -m som_seq --test:

$ python3 -m som_seq --test

**********************************************************************
File "/home/paul/test_SOMSeq/quicksom_seq/som_seq.py", line 173, in __main__.iscore_matrix_vec
Failed example:
    scores = iscore_matrix_vec(vec1, b62=b62, verbose=True)
Exception raised:
    Traceback (most recent call last):
      File "/home/paul/miniconda3/envs/WE/lib/python3.11/doctest.py", line 1350, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest __main__.iscore_matrix_vec[4]>", line 1, in <module>
        scores = iscore_matrix_vec(vec1, b62=b62, verbose=True)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/paul/test_SOMSeq/quicksom_seq/som_seq.py", line 189, in iscore_matrix_vec
        matv2 = torch.matmul(matrix[None, ...], torch.swapaxes(vec1[..., :-2], 1, 2))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat2 in method wrapper_CUDA_bmm)
**********************************************************************
1 items had failures:
   2 of   6 in __main__.iscore_matrix_vec
***Test Failed*** 2 failures.

(2) and the test_som fails with out of memory, any idea how I can improve this for my nvidia Quadro P620? Or is there a way to disable GPU and use the package on CPU alone?

$ ./test_som.sh

(...)

/tmp/zshsfGzTa opened with object id 140309483654656 for worker 16
/tmp/zshsfGzTa opened with object id 140309483654480 for worker 15
/tmp/zshsfGzTa opened with object id 140309483655184 for worker 19
/home/paul/miniconda3/envs/WE/lib/python3.11/site-packages/torch/_functorch/deprecated.py:58: UserWarning: We've integrated functorch into PyTorch. As the final step of the integration, functorch.vmap is deprecated as of PyTorch 2.0 and will be deleted in a future version of PyTorch >= 2.3. Please use torch.vmap instead; see the PyTorch 2.0 release notes and/or the torch.func migration guide for more details https://pytorch.org/docs/master/func.migrating.html
  warn_deprecated('vmap', 'torch.vmap')
1/1: 0/30 | alpha: 0.500000 | sigma: 25.000000 | error: 643.780945 | time: 0:00:00.562173 | eta: 0:00:01.124346
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/paul/test_SOMSeq/quicksom_seq/som_seq.py", line 384, in <module>
    main(ali=args.aln,
  File "/home/paul/test_SOMSeq/quicksom_seq/som_seq.py", line 315, in main
    somobj.fit(dataset=dataloader,
  File "/home/paul/test_SOMSeq/quicksom_seq/quicksom_seq/quicksom/som.py", line 402, in fit
    bmu_loc, error = self.__call__(batch, learning_rate_op=lr_step)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/test_SOMSeq/quicksom_seq/quicksom_seq/quicksom/som.py", line 317, in __call__
    delta = torch.mul(learning_rate_multiplier.reshape(*learning_rate_multiplier.size(), 1).expand_as(delta), delta)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 484.00 MiB (GPU 0; 1.95 GiB total capacity; 565.17 MiB already allocated; 401.94 MiB free; 1014.00 MiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

(3) the colab notebook fails in section 4. Compute the Self Organizing Map for the test data (human_kinome_noPLK5):

n_input: 496
opening /content/quicksom_seq/data/Human_kinome/human_kinome_noPLK5.aln

---------------------------------------------------------------------------

XlaRuntimeError                           Traceback (most recent call last)

[<ipython-input-11-ed54f830ffaa>](https://localhost:8080/#) in <cell line: 10>()
     13                scheduler="exp", alpha=alpha, sigma= sigma)
     14 else:
---> 15   som_seq.main(ali=test_aln, batch_size=10, use_jax=True,
     16                outname="som", somside=somside, nepochs=nepochs,
     17                scheduler="exp", alpha=alpha, sigma= sigma)

20 frames

[/usr/local/lib/python3.10/dist-packages/jax/_src/compiler.py](https://localhost:8080/#) in backend_compile(backend, module, options, host_callbacks)
    249   # TODO(sharadmv): remove this fallback when all backends allow `compile`
    250   # to take in `host_callbacks`
--> 251   return backend.compile(built_c, compile_options=options)
    252 
    253 

XlaRuntimeError: FAILED_PRECONDITION: DNN library initialization failed. Look at the errors above for more details.

functorch not supported

functorch is deprecated and included in newest versions of torch as torch.func. A simple workaround is to change line 51 of align_scape to something like:

import torch.func as functorch

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.