<p>I have answered my own question however, it is specific to windows users.. If you get the same error from the <code>cmd</code> as I did, you must manually put in environment variables related to Java. Do as the user Mohamed did in this SO post: <a href="https://stackoverflow.com/questions/9303889/error-occurred-during-initialization-of-vm-could-not-reserve-enough-space-for">https://stackoverflow.com/questions/9303889/error-occurred-during-initialization-of-vm-could-not-reserve-enough-space-for</a></p>

<p>Following this, you <strong>must avoid</strong> using paths such as <code>C:/absolute_path</code> and instead use <code>/absolute_path</code>, if you do the former, you will get the exception: <code>java.net.MalformedURLException: unknown protocol: c</code></p>

<p>In the end, after manually entering the environment variables and running the following command: <code>java -Xmx2G -cp /Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea2-2.2.4.jar xtools.gsea.GseaPreranked -param_file /Users/omk/Desktop/BIOINFORMATIC/MsigDB/GSEAPrerankedParameters.txt -rnk /Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea_treatFU_min.rnk -gmx /Users/omk/Desktop/BIOINFORMATIC/MsigDB/h.all.v6.2.symbols.gmt -rpt_label gsea_treatFU_min.rnk -out /Users/omk/Desktop/BIOINFORMATIC/MsigDB/C7</code> it has worked.</p>

<p>Where the command can be executed directly from the command line or in R using the <code>system</code> function. </p>

<p><strong>Note</strong>: A '#' separated by a <em>space</em> must be present at the beginning of your <code>.rnk</code> file for the program to work. Therefore, <code>.rnk</code> files must have the following format:</p>

<p><code># Genes  Coeffecients
TSPAN6    0.2345676</code> 
etc. for every gene.</p>

CC BY-SA 4.0
2019-05-03T18:52:18.090Z
2019-05-03T20:11:09.613Z
2019-05-03T20:11:09.613Z
h3ab74
<p>Are you calling java with sufficient memory? Try increasing <code>-Xmx2G</code> to <code>-Xmx8G</code>, provided your PC has 8 GB RAM.</p>

CC BY-SA 4.0
2019-05-02T14:22:11.380Z
Good call. I tried this and got the exception `Invalid maximum heap size: -Xmx8G`
h3ab74
CC BY-SA 4.0
2019-05-03T07:36:07.857Z
a quick google search suggests this might be due to 32 bit java vs 64 bit java?
Pallie
CC BY-SA 4.0
2019-05-03T14:00:44.937Z
So it actually had to do with the environment variables for Java in my computer. I had to manually insert some of them - _JAVA_OPTIONS and JAVA_HOME. Here is a SO post that was helpful: https://stackoverflow.com/questions/9303889/error-occurred-during-initialization-of-vm-could-not-reserve-enough-space-for
Unfortunately I'm still getting an error - a different one though - malformed url exception, unknown protocol C. So I'm getting closer but still no luck..
h3ab74
CC BY-SA 4.0
2019-05-02T13:51:35.800Z
2019-05-02T13:51:35.800Z
Pallie
<p>I have been trying to conduct a classic GSEA using the broad institute software and can not figure out how to compile it in R for the life of me. I am aware that there exists other packages in R that are <em>almost</em> the same, such as <code>fgsea</code> however, I would like to use this one first and then compare it with these other methods.</p>

<p>I have already generated a ranked list for my contrast of interest and save it as a <code>.rnk</code> file. Here is what I tried to do:</p>

<pre><code>gseaCallH &lt;- 
  paste("java -Xmx2G -cp C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea2-2.2.4.jar xtools.gsea.GseaPreranked -param_file C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/GSEAPrerankedParameters.txt -rnk C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea_treatFU_min.rnk -gmx C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/h.all.v6.2.symbols.gmt -rpt_label gsea_treatFU_min.rnk -out C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/C7",sep="")

testGSEA &lt;- system(command = gseaCallH, intern = TRUE, ignore.stderr = TRUE)
</code></pre>

<p>When I run the <code>system</code> command I get the following error:
<code>had status 1</code></p>

<p>At first I thought maybe it had something to do with JAVA not being properly installed however, I have installed it and still nothing. Maybe the installation was not done correctly? I have tried running it directly from cmd (I'm running windows 10) and got the following error: </p>

<pre><code>Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
</code></pre>

<p>Can anyone advise on how to proceed? </p>

CC BY-SA 4.0
2019-05-02T07:07:33.733Z
Are you sure you have the specs to run the application? Did you check the Java version?
llrs
CC BY-SA 4.0
2019-05-02T07:24:17.773Z
BTW, do you have the rJava package installed? It requires to configure R to be able to use Java (basically running `R CMD javareconf`) maybe it helps too. Because the way you run it now from R is sending it back to the command line, so you should get the error from the command line
llrs
CC BY-SA 4.0
2019-05-02T13:21:46.710Z
If by specs you mean the software then yes, I have downloaded the desktop version of the application as well
h3ab74
CC BY-SA 4.0
2019-05-02T13:24:46.050Z
Yes, then it might be a problem for their support system... Good luck
llrs
<r><rna-seq><gsea><java>
GSEA - Gene Set Enrichment Analysis - in R studio
# GSEA - Gene Set Enrichment Analysis - in R studio

(Asked by: username_0 on 2019-05-02)

I have been trying to conduct a classic GSEA using the broad institute software and can not figure out how to compile it in R for the life of me. I am aware that there exists other packages in R that are almost the same, such as fgsea however, I would like to use this one first and then compare it with these other methods.
I have already generated a ranked list for my contrast of interest and save it as a .rnk file. Here is what I tried to do:
gseaCallH <- 
  paste("java -Xmx2G -cp C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea2-2.2.4.jar xtools.gsea.GseaPreranked -param_file C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/GSEAPrerankedParameters.txt -rnk C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea_treatFU_min.rnk -gmx C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/h.all.v6.2.symbols.gmt -rpt_label gsea_treatFU_min.rnk -out C:/Users/omk/Desktop/BIOINFORMATIC/MsigDB/C7",sep="")

testGSEA <- system(command = gseaCallH, intern = TRUE, ignore.stderr = TRUE)

When I run the system command I get the following error:
had status 1
At first I thought maybe it had something to do with JAVA not being properly installed however, I have installed it and still nothing. Maybe the installation was not done correctly? I have tried running it directly from cmd (I'm running windows 10) and got the following error: 
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

Can anyone advise on how to proceed?

**Tags:** r, rna-seq, gsea, java
> **Comments:**
> **username_1**: Are you sure you have the specs to run the application? Did you check the Java version?  
> **username_1**: BTW, do you have the rJava package installed? It requires to configure R to be able to use Java (basically running `R CMD javareconf`) maybe it helps too. Because the way you run it now from R is sending it back to the command line, so you should get the error from the command line  
> **username_0**: If by specs you mean the software then yes, I have downloaded the desktop version of the application as well  
> **username_1**: Yes, then it might be a problem for their support system... Good luck  

---

## 2 answers

### Answer by username_0 on 2019-05-03. Score: 3

I have answered my own question however, it is specific to windows users.. If you get the same error from the `cmd` as I did, you must manually put in environment variables related to Java. Do as the user Mohamed did in this SO post: <https://stackoverflow.com/questions/9303889/error-occurred-during-initialization-of-vm-could-not-reserve-enough-space-for>

Following this, you **must avoid** using paths such as `C:/absolute_path` and instead use `/absolute_path`, if you do the former, you will get the exception: `java.net.MalformedURLException: unknown protocol: c`

In the end, after manually entering the environment variables and running the following command: `java -Xmx2G -cp /Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea2-2.2.4.jar xtools.gsea.GseaPreranked -param_file /Users/omk/Desktop/BIOINFORMATIC/MsigDB/GSEAPrerankedParameters.txt -rnk /Users/omk/Desktop/BIOINFORMATIC/MsigDB/gsea_treatFU_min.rnk -gmx /Users/omk/Desktop/BIOINFORMATIC/MsigDB/h.all.v6.2.symbols.gmt -rpt_label gsea_treatFU_min.rnk -out /Users/omk/Desktop/BIOINFORMATIC/MsigDB/C7` it has worked.

Where the command can be executed directly from the command line or in R using the `system` function.

**Note**: A '#' separated by a *space* must be present at the beginning of your `.rnk` file for the program to work. Therefore, `.rnk` files must have the following format:

`# Genes Coeffecients
TSPAN6 0.2345676`
etc. for every gene.


---

### Answer by username_2 on 2019-05-02. Score: 2

Are you calling java with sufficient memory? Try increasing `-Xmx2G` to `-Xmx8G`, provided your PC has 8 GB RAM.

> **Comments:**
> **username_0**: Good call. I tried this and got the exception `Invalid maximum heap size: -Xmx8G`  
> **username_2**: a quick google search suggests this might be due to 32 bit java vs 64 bit java?  
> **username_0**: So it actually had to do with the environment variables for Java in my computer. I had to manually insert some of them - _JAVA_OPTIONS and JAVA_HOME. Here is a SO post that was helpful: https://stackoverflow.com/questions/9303889/error-occurred-during-initialization-of-vm-could-not-reserve-enough-space-for Unfortunately I'm still getting an error - a different one though - malformed url exception, unknown protocol C. So I'm getting closer but still no luck..  

---

