Answers.Body: <p>Assuming <code>da</code> is a data-frame with the cluster as factor you can do the following:</p>
  
  <pre><code>ggplot(da) +
    geom_boxplot(aes(cluster, H4)) +
    xlab("Cluster") +
    ylab("Genes") +
    ggtitle("Genes by Cluster")
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-19T07:37:58.323Z
Answers.Text: okay i did something similar  made factor of the clust column then melt  using  melt(da, id.vars=c("clust")) the plot , I got all the cluster expression together..
Answers.UserDisplayName: kcm
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-19T07:21:37.583Z
Answers.LastActivityDate: 2018-09-19T07:21:37.583Z
Answers.UserDisplayName: llrs
Body: <pre><code> gene   H4       H3       H2       H1       L8       L7       L6       L5       L4       L3       L2       L1          clust
  AAGAB  7.540712 7.296325 7.030218 7.408974 8.269541 7.758752 9.253013 8.611002 8.705045 8.940146 8.855133 8.488776     3
  ABCA1  7.112951 6.213973 7.200973 6.784828 8.044299 9.832347 8.558342 7.134570 8.993938 5.794208 8.271960 9.179501     5
  ABCA6  1.822567 2.209167 3.379618 2.813433 3.180290 3.741516 3.060194 2.078485 6.536346 6.881403 5.927874 5.278854     2
  </code></pre>
  
  <p>This is my output after doing kmean clustering so at the end I have my cluster number assigned to each gene. Now I want to show how the expression of my sample varies across each cluster, I am not sure how to transform the data and do it in <code>ggplot2</code> as of now i doing something like this in base R plot </p>
  
  <pre><code>boxplot(da$H4 ~ k$cluster, 
          xlab='Cluster', ylab='Genes', 
          main=' Genes by Cluster')
  </code></pre>
  
  <p>For each sample I am checking, is there any way to show that with all the samples together, any suggestion or help would be highly appreciated.</p>
  
Tags: <r><visualization>
Title: Boxplot of kmean cluster
ThreadText: # Boxplot of kmean cluster
  
  (Asked by: username_0 on 2018-09-18)
  
  ```
   gene   H4       H3       H2       H1       L8       L7       L6       L5       L4       L3       L2       L1          clust
  AAGAB  7.540712 7.296325 7.030218 7.408974 8.269541 7.758752 9.253013 8.611002 8.705045 8.940146 8.855133 8.488776     3
  ABCA1  7.112951 6.213973 7.200973 6.784828 8.044299 9.832347 8.558342 7.134570 8.993938 5.794208 8.271960 9.179501     5
  ABCA6  1.822567 2.209167 3.379618 2.813433 3.180290 3.741516 3.060194 2.078485 6.536346 6.881403 5.927874 5.278854     2
  
  ```
  
  This is my output after doing kmean clustering so at the end I have my cluster number assigned to each gene. Now I want to show how the expression of my sample varies across each cluster, I am not sure how to transform the data and do it in `ggplot2` as of now i doing something like this in base R plot
  
  ```
  boxplot(da$H4 ~ k$cluster, 
          xlab='Cluster', ylab='Genes', 
          main=' Genes by Cluster')
  
  ```
  
  For each sample I am checking, is there any way to show that with all the samples together, any suggestion or help would be highly appreciated.
  
  **Tags:** r, visualization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-19. Score: 1 | Accepted answer
  
  Assuming `da` is a data-frame with the cluster as factor you can do the following:
  
  ```
  ggplot(da) +
    geom_boxplot(aes(cluster, H4)) +
    xlab("Cluster") +
    ylab("Genes") +
    ggtitle("Genes by Cluster")
  
  ```
  
  > **Comments:**
  > **username_0**: okay i did something similar  made factor of the clust column then melt  using  melt(da, id.vars=c("clust")) the plot , I got all the cluster expression together..  
  
  ---
  
  