sourmashconsumr icon indicating copy to clipboard operation
sourmashconsumr copied to clipboard

Importing distance.cmp into R

Open UniAlberta opened this issue 1 year ago • 7 comments
trafficstars

Hi, I ran sourmash sketch dna ~/*.fastq.gz on my fasta files and then sourmash compare *.sig -o distances.cmp -k 31. Now I have distance.cmp output file and I want to use it in R to plot ordination. I`m not sure how I can import .cmp file into R. Is there any code for that? Thanks

UniAlberta avatar Oct 05 '24 05:10 UniAlberta

hi @UniAlberta, you'll want to use the --csv output instead - the .cmp file is a numpy binary matrix file that is probably more difficult to read into R!

Here's some example code: https://sourmash.readthedocs.io/en/latest/other-languages.html#r-code-for-working-with-compare-output

ctb avatar Oct 05 '24 10:10 ctb

Thanks for your reply. I have all my .files and when I try to run sourmash compare *.sig --csv distance.cmp.csv, I get an error of ModuleNotFoundError: No module named 'numpy'. Could you please help to fix it? Here`s the info from my smash (smash) ...@...:~/miniforge3/envs/smash/lib/python3.9/site-packages/sourmash$ ls init.py _lowlevel.py cli commands.py fig.py lca nodegraph.py sbt_storage.py sig utils.py main.py _lowlevel__ffi.py command_compute.py compare.py hll.py logging.py np_utils.py sbtmh.py signature.py version.py pycache _lowlevel__lib.so command_sketch.py exceptions.py index.py minhash.py sbt.py search.py sourmash_args.py

UniAlberta avatar Oct 05 '24 21:10 UniAlberta

that's weird - what command did you use to install sourmash?

In any case, after activating the conda environment, you should be able to use

pip install numpy

or

conda install numpy

ctb avatar Oct 05 '24 22:10 ctb

I follow this for installation https://sourmash.readthedocs.io/en/latest/tutorial-install.html. I run conda install numpy and then when I`m in smash environment, I run sourmash compare *.sig --csv distance.cmp.csv and it gives me the same error. ModuleNotFoundError: No module named 'numpy'. Have you updated the tool? Because I ran it last week and it worked

UniAlberta avatar Oct 06 '24 01:10 UniAlberta

Nope, no updates. And in any case that wouldn't have broken your conda environment!

I'm wondering if maybe your conda environment activation is somehow messed up - try logging in again/starting a new shell, and then activating the smash environment again. conda list should show that numpy is installed, along with sourmash.

ctb avatar Oct 06 '24 11:10 ctb

I tried pip3 install numpy and it worked. Thanks for your help.

UniAlberta avatar Oct 07 '24 00:10 UniAlberta

fantastic!

please feel free to ask for help here or elsewhere - more people monitor https://github.com/dib-lab/sourmash/issues so that's a good place to go :)

ctb avatar Oct 07 '24 10:10 ctb