参考文献1,2. 示例代码: # Function to compute the smooth threshold curve smooth.threshold=function(x,ta,s0,df){ xp=x[x>(ta*s0)]; xn=x[x<(-ta*s0)]; dp=xp/ta-s0; dn=xn/(-ta)-s0; dp=s0/dp; dp=ta*(1+dp); dn=s0/dn; dn=ta*(1+dn); fp=pt(dp,df=df); fn=pt(dn,df=df); yp=-log10(2*(1-fp)); yn=-log10(2*(1-fn)); return(cbind(c(xn,xp),c(yn,yp))); } # Get data library(cp4p); data(LFQRatio2); tabl=LFQRatio2; ## Warning: package 'cp4p' was built under R version 3.6.1 ## Loading required package: MESS ## Warning: package 'MESS' was built under R version 3.6.1 ## Loading required
使用ggplot2画蝴蝶图. library(tidyverse) ## Warning: package 'tidyverse' was built under R version 3.6.1 ## -- Attaching packages ------------------------------------------------------------------------ tidyverse 1.2.1 -- ## v ggplot2 3.2.1 v purrr 0.3.2 ## v tibble 2.1.3 v dplyr 0.8.3 ## v tidyr 1.0.0 v stringr 1.4.0 ## v readr 1.3.1 v forcats 0.4.0 ## Warning: package 'ggplot2' was built under R version