Body: <p>I intend to see data points distribution (each reows) within labeled groups (different batchs such as 1,2,3, and so on) in 3D scatter plot, because I want to see the distribution of the data points and want to see how similar each group of data points in 3D space. To do so, I used <code>scatterplot3d</code> package from CRAN to get 3D scatter plot, didn't get correct plot for my data.</p>
  
  <p><strong>reproducible data:</strong></p>
  
  <p>Here is the reproducible data that simulated from the original dataset.</p>
  
  <pre><code>persons_df &lt;- data.frame(ID= LETTERS[1:20], ages=sample(1:50,20, replace = FALSE),
                      batch=c(rep(1,5), rep(2,6),rep(3,4),rep(4,5)),
                      platform=c(rep("CATH",12), rep("ANN",8)))
  </code></pre>
  
  <p>basically, I want to render 3D plot for the data points that belongs to the same batch with the same color (1 is red, 2 is blue, 3 is green, 4 is yellow).</p>
  
  <p><strong>this was my attempt to render PCA plot</strong></p>
  
  <pre><code>require(scatterplot3d)
  par(mar=c(4,4,4,4), cex=1.0, cex.main=0.8, cex.axis=0.8)
  scatterplot3d(persons_df$batch)
  </code></pre>
  
  <p>but above code doesn't work because first I should group data points that belongs to different batches then render them in 3D space. This is not very intuitive to me how to do it in R? Any idea to render possible 3D scatter plot for my data? any thought?</p>
  
  <p><strong>desired 3D plot</strong>:</p>
  
  <p>I want 3D plot something like this:</p>
  
  <p><a href="https://i.sstatic.net/fkTH6.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fkTH6.jpg" alt="enter image description here"></a></p>
  
  <p>how can I make this happen? any idea to get this done?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-10T23:58:52.990Z
Comments.Text: PCA doesn't make sense here. PCA is a dimensional scaling technique. When we use PCA, we are trying to represent (usually) highly dimensional data in two or three dimesnions. For example, in the example you linked `prcomp(iris[, -5])` is performing PCA on sepal length, sepal width, petal length, and petal width. So we have 4 dimensions here. 
  
  In your reproducible example, you only have two dimensions to look at, Age and Batch. Number of dimensions aside, I think you are missing the useful data on which it would be useful to apply PCA. This is just metadata.
Comments.UserDisplayName: Kohl Kinning
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-11T00:01:18.667Z
Comments.Text: @KohlKinning agreed, I am going to rephrase my question. I need 3D scatter plot to see data points (a.k.a, number of rows that belongs to different batch). Do you have any idea?
Comments.UserDisplayName: Jerry07
Tags: <r><microarray><ggplot2>
Title: How can I correctly get 3D scatter plot for micro-array pheno data in R [updated]?
ThreadText: # How can I correctly get 3D scatter plot for micro-array pheno data in R [updated]?
  
  (Asked by: username_0 on 2019-07-08)
  
  I intend to see data points distribution (each reows) within labeled groups (different batchs such as 1,2,3, and so on) in 3D scatter plot, because I want to see the distribution of the data points and want to see how similar each group of data points in 3D space. To do so, I used `scatterplot3d` package from CRAN to get 3D scatter plot, didn't get correct plot for my data.
  
  **reproducible data:**
  
  Here is the reproducible data that simulated from the original dataset.
  
  ```
  persons_df <- data.frame(ID= LETTERS[1:20], ages=sample(1:50,20, replace = FALSE),
                      batch=c(rep(1,5), rep(2,6),rep(3,4),rep(4,5)),
                      platform=c(rep("CATH",12), rep("ANN",8)))
  
  ```
  
  basically, I want to render 3D plot for the data points that belongs to the same batch with the same color (1 is red, 2 is blue, 3 is green, 4 is yellow).
  
  **this was my attempt to render PCA plot**
  
  ```
  require(scatterplot3d)
  par(mar=c(4,4,4,4), cex=1.0, cex.main=0.8, cex.axis=0.8)
  scatterplot3d(persons_df$batch)
  
  ```
  
  but above code doesn't work because first I should group data points that belongs to different batches then render them in 3D space. This is not very intuitive to me how to do it in R? Any idea to render possible 3D scatter plot for my data? any thought?
  
  **desired 3D plot**:
  
  I want 3D plot something like this:
  
  [![enter image description here](https://i.sstatic.net/fkTH6.jpg)](https://i.sstatic.net/fkTH6.jpg)
  
  how can I make this happen? any idea to get this done?
  
  **Tags:** r, microarray, ggplot2
  
  > **Comments:**
  > **username_1**: PCA doesn't make sense here. PCA is a dimensional scaling technique. When we use PCA, we are trying to represent (usually) highly dimensional data in two or three dimesnions. For example, in the example you linked `prcomp(iris[, -5])` is performing PCA on sepal length, sepal width, petal length, and petal width. So we have 4 dimensions here.   In your reproducible example, you only have two dimensions to look at, Age and Batch. Number of dimensions aside, I think you are missing the useful data on which it would be useful to apply PCA. This is just metadata.  
  > **username_0**: @username_1 agreed, I am going to rephrase my question. I need 3D scatter plot to see data points (a.k.a, number of rows that belongs to different batch). Do you have any idea?  
  
  ---
  
  ## 0 answers
  
  