Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your names end with 'df', which makes it seem like your data are a data.frame. But @Troy's answer uses a matrix. A matrix is appropriate when the data are homogeneous, and generally matrix operations are much faster than data.frame operations. So you can see already that if you'd provided a small example of your data set (e.g., <code>dput(mRNAdf[1:10,])</code> that people might be in a better position to help you; this is what they're asking for.</p> <p>In large numerical calculations it makes sense to 'hoist' any repeated calculations outside the loop, so they are performed only once. Repeated calculations in your case include sub-setting to columns 2:13, and coercion to numeric. With this idea, and guessing that you actually have a data.frame where each column is already a numeric vector, I'd start with</p> <pre><code>mRNAmatrix &lt;- as.matrix(mRNAdf[,2:13]) miRmatrix &lt;- as.matrix(miRdf[,2:13]) </code></pre> <p>From the help page <code>?cor</code> we see that the arguments can be a matrix, and if so the correlation is calculated between columns. You're interested in the result when the arguments are transposed relative to your current representation. So</p> <pre><code>result &lt;- cor(t(mRNAmatrix), t(miRmatrix), use="complete.obs") </code></pre> <p>This is fast enough for your purposes</p> <pre><code>&gt; m1 = matrix(rnorm(71521 * 12), 71521) &gt; m2 = matrix(rnorm(1477 * 12), 1477) &gt; system.time(ans &lt;- cor(t(m1), t(m2))) user system elapsed 9.124 0.200 9.340 &gt; dim(ans) [1] 71521 1477 </code></pre> <p><code>result</code> is the same as your <code>corrList</code> -- it's not a list, but a matrix; probably the row and column names have been carried forward. You'd write this to a file as you do above, <code>write.csv(result, "testCorrWhole.csv")</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload