Entering edit mode
3.1 years ago
keren.danan
▴
20
Hello, I am trying to create a linear regression model for each gene, such that x axis is the time in hours the data was collected (single-cell data) and the y axis is the expression of gene - in log2pm. The problem is that creating violin plot suggests that the X scale is dicrete, so each object is "close" to each other object as the same distance as to others while the time differences are not equal. Here is an example:
Here is what I tried to do to extend the x limits but with no success.
Any idea?
Here is my code:
p <- ggplot(interesting_gene, aes(x = factor(Stage), y = CALM1A, color = factor(Stage))) +
geom_violin(scale = "width") +
geom_abline(slope=fit_lm$coefficients[2], intercept=fit_lm$coefficients[1], lwd=.8, color='black')+
geom_abline(slope=fit_lm1$coefficients[2], intercept=fit_lm1$coefficients[1], lwd=.8, color='blue')+
theme_bw() +
theme(legend.position = 'none')+
xlab("Developmental Stage in hours")+
labs(title=plot_title)+
scale_x_discrete(limits = c(0.3:12.3))+
ylim(0,8)+
ylab("Expression in log2TPM")
p
The time points are: 3.3,3.8,4.3,4.8,5.3,6,7...,12