casbap / ncRNA

0 stars 1 forks source link

This ggplot throws an error #2

Open markziemann opened 2 years ago

markziemann commented 2 years ago

https://github.com/casbap/ncRNA/blob/c5533e06dd70bac608dba7eb0f75598098e0e0e4/HumanDataPrep.Rmd#L196

> ggplot(hClust, aes(A, B)) +
+   geom_point()
Error in `fortify()`:
! `data` must be a data frame, or other object coercible by `fortify()`, not an S3 object with class hclust.
Run `rlang::last_error()` to see where the error occurred.

The structure of hClust is weird as it isn't a dataframe but a list. The first object in the list is a matrix.


> str(hClust)
List of 7
 $ merge      : int [1:54555, 1:2] -6 -1054 -1100 -1633 -1636 -1800 -2393 -2523 -2806 -3091 ...
 $ height     : num [1:54555] 0 0 0 0 0 0 0 0 0 0 ...
 $ order      : int [1:54556] 42060 46853 46854 20524 20528 24293 19322 23457 45967 17300 ...
 $ labels     : chr [1:54556] "ENSG00000223972" "ENSG00000227232" "ENSG00000278267" "ENSG00000243485" ...
 $ method     : chr "complete"
 $ call       : language hclust(d = distClust, method = "complete")
 $ dist.method: NULL
 - attr(*, "class")= chr "hclust"
> str(hClust[[1]])
 int [1:54555, 1:2] -6 -1054 -1100 -1633 -1636 -1800 -2393 -2523 -2806 -3091 ...
> str(hClust[[2]])
 num [1:54555] 0 0 0 0 0 0 0 0 0 0 ...
> str(hClust[[3]])
 int [1:54556] 42060 46853 46854 20524 20528 24293 19322 23457 45967 17300 ...
> str(hClust[[4]])
 chr [1:54556] "ENSG00000223972" "ENSG00000227232" "ENSG00000278267" ...
> str(hClust[[5]])
 chr "complete"
> head(hClust[[1]])
      [,1] [,2]
[1,]    -6 -487
[2,] -1054    1
[3,] -1100    2
[4,] -1633    3
[5,] -1636    4
[6,] -1800    5

I will skip it for now but it might cause downstream issues

casbap commented 2 years ago

I'm thinking converting this to a data frame may infact fix our matrix size issues, as well as make that bloody plot finally work