background
There are two files named tsne_plot and feature_all. tsne_plot contains 882 objects and 2D data for each object. I want to use tsne_plot to plot some scatterplots and map the side information comes from feature_all to these points.
an example just like this and it works very well
{r}
trait_p <- ggplot(tsne_plot, aes(x = tSNE1, y = tSNE2, colour = feature_all$Disk.diameter))+
geom_point(size = 5, alpha = 1, show.legend = TRUE) +
scale_color_continuous_sequential(palette = "Viridis", rev = FALSE) +
labs(x = "tSNE1", y = "tSNE2", colour = "disk diameter") +
theme_classic()
print(trait_p)
question
However, there is a lot of side-information in feature_all, and plotting it one by one would be very tedious.
l want to batch drawing using for
. I'm getting an error
Warning: Unknown or uninitialised column: i
.
and these code just plot 3 same scatters without color mapping.
{r}
for (i in colnames(feature_all)[1027:1029]){
trait_p <- ggplot(tsne_plot, aes(x = tSNE1, y = tSNE2, colour = feature_all$i ))+
geom_point() +
scale_color_continuous_sequential(palette = "Viridis", rev = FALSE) +
labs(x = "tSNE1", y = "tSNE2") +
theme_classic()
print(trait_p)
}