library(ggplot2)
library(tidyverse)
data <- rio::import("feature_data.csv")
head(data)
## V1 RT MZ HM406CO HM406TI
## 1 1 10796.529 758.7182 571378900 892453000
## 2 2 2401.951 567.7810 123186400 275041400
## 3 3 6875.550 745.8741 111862000 24649640000
## 4 4 2652.142 559.2601 24696700000 202261700000
## 5 5 5240.814 497.2680 207267400 224841200
## 6 6 5854.177 631.8063 NA 11582590000
Any scatter plot function can visualize the 2d MS data easily, but not able to change the wide and height of the point. geom_tile has some hidden parameters to deal with that. The data mapping is
Here we use a real feature data to demo.
plot(data[,c(2,3)], pch = 16, cex = 0.2)
With ggplot2(ggtile), it is easy to map the intensity into the color, with NA values set to grey
In ggtile, there are two hidden paras, height and width, most of the time, default settings will be good enough. However, if too many points or two few distant points, they will not/hardly visible
data_small <- data.frame(X =sample(1:30,20), Y = sample(500:600,20), Z = sample(1:100000,100))
ggplot(data_small, aes(X, Y, fill= Z)) +geom_tile()
data_small <- data.frame(X =sample(1:3000,100), Y = sample(400:1600,100), Z = sample(1:100000,100))
ggplot(data_small, aes(X, Y, fill= Z)) +geom_tile()
Therefore, the hight and width needs to be properly set for complicated data.
ggplot(data, aes(RT, MZ, fill= HM406CO)) +geom_tile(height = 10, width = 10)
ggplot(data, aes(RT, MZ, fill= HM406CO)) +geom_tile(height = 20, width = 50)