# qiime2R error GreenGenes2 tree

**URL:** https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071
**Category:** Other Bioinformatics Tools
**Tags:** qiime2r, greengenes2
**Created:** [October 25, 2023, 2:41pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071 "2023-10-25T14:41:21Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![liekekuiper](https://forum.qiime2.org/user_avatar/forum.qiime2.org/liekekuiper/32/16984_2.png) [@liekekuiper](https://forum.qiime2.org/u/liekekuiper)
#### Post date: [October 25, 2023, 2:41pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/1 "2023-10-25T14:41:21Z")

</div>

When running the following script in R:

library("qiime2R")  
tree = read\_qza("2022.10.taxonomy.asv.nwk.qza") #greengenes2 tree

I keep getting this error. How would could we avoid this?

Error in scan(file = file, what = "", sep = "\n", quiet = TRUE, skip = skip, :  
could not allocate memory (2048 Mb) in C function 'R\_AllocStringBuf

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [October 25, 2023, 4:24pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/2 "2023-10-25T16:24:24Z")

</div>

Good afternoon,

> [@liekekuiper](#):
>
> could not allocate memory (2048 Mb) in C function 'R\_AllocStringBuf

This sounds like a memory / RAM limitation.

How much memory does your computer or VM have?  
Do you have access to any computers or HPC with more memory?

---

<div class="post-metadata">

### Author: ![liekekuiper](https://forum.qiime2.org/user_avatar/forum.qiime2.org/liekekuiper/32/16984_2.png) [@liekekuiper](https://forum.qiime2.org/u/liekekuiper)
#### Post date: [October 25, 2023, 6:07pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/3 "2023-10-25T18:07:45Z")

</div>

I have assigned 64GB to this, so that shouldn't cause any issue... But you haven't encountered this before?

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [October 25, 2023, 6:10pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/4 "2023-10-25T18:10:21Z")

</div>

Something strange is going on, because...

> [@liekekuiper](#):
>
> I have assigned 64GB to this

> [@liekekuiper](#):
>
> could not allocate memory (2048 Mb)

64GB is plenty, but it's clearly not being found. 🤔

Are you running this on a VM or an HPC slurm queue? Do any other clues come to mind?

---

<div class="post-metadata">

### Author: ![liekekuiper](https://forum.qiime2.org/user_avatar/forum.qiime2.org/liekekuiper/32/16984_2.png) [@liekekuiper](https://forum.qiime2.org/u/liekekuiper)
#### Post date: [October 25, 2023, 7:03pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/5 "2023-10-25T19:03:03Z")

</div>

A HPC slurm queue; The only thing I could imagine is there being an issue with the artifact, but that doesn't make any sense as 1) it is the designated tree and 2) I was able to use the artifact in all steps so far...

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [October 26, 2023, 1:27pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/6 "2023-10-26T13:27:02Z")

</div>

Ah, are you submitting jobs to the slurm queue or running with a workflow manager like Snakemake or NextFlow?

Can you post the code / template you are using to submit jobs?

(I ask because I myself have carefully crafted a submission scripts to run 64 threads in parallel, only to realize that I was actually getting 1/64th of the CPU I wanted. Slurm is tricky 🙀 )

---

<div class="post-metadata">

### Author: ![liekekuiper](https://forum.qiime2.org/user_avatar/forum.qiime2.org/liekekuiper/32/16984_2.png) [@liekekuiper](https://forum.qiime2.org/u/liekekuiper)
#### Post date: [October 27, 2023, 11:41am UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/9 "2023-10-27T11:41:39Z")

</div>

Yes, you are right, slurm can be full of surprises... 😅  
I used the following scripts:

sbatch physeq.sbatch

With physeq.sbatch being:

#!/bin/bash

#SBATCH -N 1

#SBATCH -c 1

#SBATCH --time 1:00:00

#SBATCH --mem=64G

#SBATCH -J physeq

set -x

set -e

Rscript --vanilla physeq.R

And physeq.R being:

library("phyloseq")

library("qiime2R")

# read in phyloseq objects from qiime

physeq\<-qza\_to\_phyloseq(

features="features.gg2.qza",

tree="2022.10.phylogeny.asv.nwk.qza",

taxonomy = "gg2.taxonomy.qza",

metadata = "../Metadata.txt")

write\_phyloseq(physeq, type = "all", path = getwd())

Resulting in:

- set -e

- Rscript --vanilla physeq.R

Error in scan(file = file, what = "", sep = "\n", quiet = TRUE, skip = skip, :

could not allocate memory (2048 Mb) in C function 'R\_AllocStringBuffer'

Calls: qza\_to\_phyloseq -\> read\_qza -\> read.tree -\> scan

Execution halted

And as shown above I receive the same error when reading in read\_qza("2022.10.taxonomy.asv.nwk.qza")

Do you have any clue what I am doing wrong?

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [October 29, 2023, 4:01am UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/10 "2023-10-29T04:01:43Z")

</div>

Your slurm setup looks okay!

```sh
#SBATCH -N 1
#SBATCH -c 1

```

With one Node and one processor Core, this job will use a single CPU core on a single node for its execution, fine for simple R.

```sh
#SBATCH --mem=64G

```

And this gives you 64 Gigs. Plenty!

* * *

> [@liekekuiper](#):
>
> Do you have any clue what I am doing wrong?

You are doing everything right.

Have you asked the HPC team about this? They would have more tools to troubleshoot...

That tree has trees \>20M vertices. You may need more RAM.  
(The HPC could help with that too!)

---

<div class="post-metadata">

### Author: ![wasade](https://forum.qiime2.org/user_avatar/forum.qiime2.org/wasade/32/2317_2.png) [@wasade](https://forum.qiime2.org/u/wasade)
#### Post date: [October 30, 2023, 11:12pm UTC](https://forum.qiime2.org/t/qiime2r-error-greengenes2-tree/28071/11 "2023-10-30T23:12:11Z")

</div>

Hi @liekekuiper,

What actions in phyloseq would you like to perform?

It's plausible that it's underlying tree data structure isn't suited for the size of the Greengenes2 tree. If that's the case, subsetting the phylogeny to the feature table prior to load into R may work. `qiime phylogeny filter-tree` could work for that though I haven't evaluated it directly for use with the current tree.

Best,  
Daniel
