R 学习 - 线图
更多生信和Linux學習,程序寫作,請掃描關注生信寶典。
https://mp.weixin.qq.com/mp/homepage?__biz=MzI5MTcwNjA4NQ==&hid=6&sn=667813e1f021e2cf155a74457b48d087&scene=18&uin=&key=&devicetype=Windows+UnKnow&version=62040549&lang=zh_CN&ascene=7&winzoom=1
線圖
線圖是反映趨勢變化的一種方式,其輸入數據一般也是一個矩陣。
單線圖
假設有這么一個矩陣,第一列為轉錄起始位點及其上下游5 kb的區域,第二列為H3K27AC修飾在這些區域的豐度,想繪制一張線圖展示。
profile="Pos;H3K27ac -5000;8.7 -4000;8.4 -3000;8.3 -2000;7.2 -1000;3.6 0;3.6 1000;7.1 2000;8.2 3000;8.4 4000;8.5 5000;8.5"讀入數據 (經過前面幾篇的聯系,這應該都很熟了)
profile_text <- read.table(text=profile, header=T, row.names=1, quote="",sep=";") profile_text H3K27ac -5000 8.7 -4000 8.4 -3000 8.3 -2000 7.2 -1000 3.6 0 3.6 1000 7.1 2000 8.2 3000 8.4 4000 8.5 5000 8.5 # 在melt時保留位置信息 # melt格式是ggplot2畫圖最喜歡的格式 # 好好體會下這個格式,雖然多占用了不少空間,但是確實很方便# 這里可以用 `xvariable`,也可以是其它字符串,但需要保證后面與這里的一致 # 因為這一列是要在X軸顯示,所以起名為`xvariable`。 profile_text$xvariable = rownames(profile_text) library(ggplot2) library(reshape2) data_m <- melt(profile_text, id.vars=c("xvariable")) data_m xvariable variable value 1 -5000 H3K27ac 8.7 2 -4000 H3K27ac 8.4 3 -3000 H3K27ac 8.3 4 -2000 H3K27ac 7.2 5 -1000 H3K27ac 3.6 6 0 H3K27ac 3.6 7 1000 H3K27ac 7.1 8 2000 H3K27ac 8.2 9 3000 H3K27ac 8.4 10 4000 H3K27ac 8.5 11 5000 H3K27ac 8.5然后開始畫圖,與上面畫heatmap一樣。
# variable和value為矩陣melt后的兩列的名字,內部變量, variable代表了點線的屬性,value代表對應的值。 p <- ggplot(data_m, aes(x=xvariable, y=value),color=variable) + geom_line() p # 圖會存儲在當前目錄的Rplots.pdf文件中,如果用Rstudio,可以不運行dev.off() dev.off()滿心期待一個倒鐘形曲線,結果,
什么也沒有。
仔細看,出來一段提示
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?原來默認ggplot2把每個點都視作了一個分組,什么都沒畫出來。而data_m中的數據都來源于一個分組H3K27ac,分組的名字為variable,修改下腳本,看看效果。
p <- ggplot(data_m, aes(x=xvariable, y=value,color=variable,group=variable)) + geom_line() + theme(legend.position=c(0.1,0.9)) p dev.off()圖出來了,一條線,看一眼沒問題;再仔細看,不對了,怎么還不是倒鐘形,原來橫坐標錯位了。
檢查下數據格式
summary(data_m) xvariable variable value Length:11 H3K27ac:11 Min. :3.600 Class :character 1st Qu.:7.150 Mode :character Median :8.300 Mean :7.318 3rd Qu.:8.450 Max. :8.700問題來了,xvariable雖然看上去數字,但存儲的實際是字符串 (因為是作為行名字讀取的),需要轉換為數字。
data_m$xvariable <- as.numeric(data_m$xvariable)#再檢驗下 is.numeric(data_m$xvariable) [1] TRUE好了,繼續畫圖。
# 注意斷行時,加號在行尾,不能放在行首 p <- ggplot(data_m, aes(x=xvariable, y=value,color=variable,group=variable)) +geom_line() + theme(legend.position=c(0.1,0.8)) p dev.off()圖終于出來了,調了下legend的位置,看上去有點意思了。
有點難看,如果平滑下,會不會好一些,stat_smooth可以對繪制的線進行局部擬合。在不影響變化趨勢的情況下,可以使用 (但慎用)。
p <- ggplot(data_m, aes(x=xvariable, y=value,color=variable,group=variable)) + geom_line() + stat_smooth(method="auto", se=FALSE) + theme(legend.position=c(0.1,0.8)) p dev.off()從圖中看,趨勢還是一致的,線條更優美了。另外一個方式是增加區間的數量,線也會好些,而且更真實。
stat_smooth和geom_line各繪制了一條線,只保留一條就好。
p <- ggplot(data_m, aes(x=xvariable, y=value,color=variable,group=variable)) + stat_smooth(method="auto", se=FALSE) + theme(legend.position=c(0.1,0.8)) p dev.off()好了,終于完成了單條線圖的繪制。
多線圖
那么再來一個多線圖的例子吧,只要給之前的數據矩陣多加幾列就好了。
profile = "Pos;h3k27ac;ctcf;enhancer;h3k4me3;polII -5000;8.7;10.7;11.7;10;8.3 -4000;8.4;10.8;11.8;9.8;7.8 -3000;8.3;10.5;12.2;9.4;7 -2000;7.2;10.9;12.7;8.4;4.8 -1000;3.6;8.5;12.8;4.8;1.3 0;3.6;8.5;13.4;5.2;1.5 1000;7.1;10.9;12.4;8.1;4.9 2000;8.2;10.7;12.4;9.5;7.7 3000;8.4;10.4;12;9.8;7.9 4000;8.5;10.6;11.7;9.7;8.2 5000;8.5;10.6;11.7;10;8.2"profile_text <- read.table(text=profile, header=T, row.names=1, quote="",sep=";")profile_text$xvariable = rownames(profile_text) data_m <- melt(profile_text, id.vars=c("xvariable")) data_m$xvariable <- as.numeric(data_m$xvariable)# 這里group=variable,而不是group=1 (如果上面你用的是1的話) # variable和value為矩陣melt后的兩列的名字,內部變量, variable代表了點線的屬性,value代表對應的值。 p <- ggplot(data_m, aes(x=xvariable, y=value,color=variable,group=variable)) + stat_smooth(method="auto", se=FALSE) + theme(legend.position=c(0.85,0.2)) p dev.off()橫軸文本線圖
如果橫軸是文本,又該怎么調整順序呢?還記得之前熱圖旁的行或列的順序調整嗎?重新設置變量的factor水平就可以控制其順序。
profile = "Pos;h3k27ac;ctcf;enhancer;h3k4me3;polII -5000;8.7;10.7;11.7;10;8.3 -4000;8.4;10.8;11.8;9.8;7.8 -3000;8.3;10.5;12.2;9.4;7 -2000;7.2;10.9;12.7;8.4;4.8 -1000;3.6;8.5;12.8;4.8;1.3 0;3.6;8.5;13.4;5.2;1.5 1000;7.1;10.9;12.4;8.1;4.9 2000;8.2;10.7;12.4;9.5;7.7 3000;8.4;10.4;12;9.8;7.9 4000;8.5;10.6;11.7;9.7;8.2 5000;8.5;10.6;11.7;10;8.2"profile_text <- read.table(text=profile, header=T, row.names=1, quote="",sep=";")profile_text_rownames <- row.names(profile_text)profile_text$xvariable = rownames(profile_text) data_m <- melt(profile_text, id.vars=c("xvariable")) data_m$xvariable <- factor(data_m$xvariable, levels=profile_text_rownames, ordered=T)# geom_line設置線的粗細和透明度 p <- ggplot(data_m, aes(x=xvariable, y=value,color=variable,group=variable)) + geom_line(size=1, alpha=0.9) + theme(legend.position=c(0.85,0.2)) +theme(axis.text.x=element_text(angle=45,hjust=1, vjust=1))# stat_smooth #p <- ggplot(data_m, aes(x=xvariable, y=value,color=variable,group=variable)) + # stat_smooth(method="auto", se=FALSE) + theme(legend.position=c(0.85,0.2)) + # theme(axis.text.x=element_text(angle=45,hjust=1, vjust=1))p dev.off()比較下位置信息做為數字(前面的線圖)和位置信息橫軸的差別。當為數值時,ggplot2會選擇合適的幾個刻度做標記,當為文本時,會全部標記。另外文本橫軸,smooth效果不明顯 (下面第2張圖)。
至此完成了線圖的基本繪制,雖然還可以,但還有不少需要提高的地方,比如在線圖上加一條或幾條垂線、加個水平線、修改X軸的標記(比如0換為TSS)、設置每條線的顏色等。具體且聽下回一步線圖法。
線圖 - 一步繪制
繪圖時通常會碰到兩個頭疼的問題:
有時需要繪制很多的圖,唯一的不同就是輸入文件,其它都不需要修改。如果用R腳本,需要反復替換文件名,繁瑣又容易出錯。 (R也有命令行參數,不熟,有經驗的可以嘗試下)
每次繪圖都需要不斷的調整參數,時間久了不用,就忘記參數怎么設置了;或者調整次數過多,有了很多版本,最后不知道用哪個了。
為了簡化繪圖、維持腳本的一致,我用bash對繪圖命令做了一個封裝,通過配置修改命令行參數,生成相應的繪圖腳本,然后再繪制。
首先把測試數據存儲到文件中方便調用。數據矩陣存儲在line_data.xls和line_data_melt.xls文件中 (直接拷貝到文件中也可以,這里這么操作只是為了隨文章提供個測試文件,方便使用。如果你手上有自己的數據,也可以拿來用)。
profile = "Pos;H3K27ac;CTCF;Enhancer;H3K4me3;polII -5000;8.7;10.7;11.7;10;8.3 -4000;8.4;10.8;11.8;9.8;7.8 -3000;8.3;10.5;12.2;9.4;7 -2000;7.2;10.9;12.7;8.4;4.8 -1000;3.6;8.5;12.8;4.8;1.3 0;3.6;8.5;13.4;5.2;1.5 1000;7.1;10.9;12.4;8.1;4.9 2000;8.2;10.7;12.4;9.5;7.7 3000;8.4;10.4;12;9.8;7.9 4000;8.5;10.6;11.7;9.7;8.2 5000;8.5;10.6;11.7;10;8.2"profile_text <- read.table(text=profile, header=T, row.names=1, quote="",sep=";") # tab鍵分割,每列不加引號 write.table(profile_text, file="line_data.xls", sep="\t", row.names=T, col.names=T,quote=F) # 如果看著第一行少了ID列不爽,可以填補下 system("sed -i '1 s/^/ID\t/' line_data.xls") profile = "Pos;variable;value;set -5000;H3K27ac;8.71298;A -4000;H3K27ac;8.43246;A -3000;H3K27ac;8.25497;A -2000;H3K27ac;7.16265;A -1000;H3K27ac;3.55341;A 0;H3K27ac;3.5503;A 1000;H3K27ac;7.07502;A 2000;H3K27ac;8.24328;A 3000;H3K27ac;8.43869;A 4000;H3K27ac;8.48877;A -5000;CTCF;10.6913;A -4000;CTCF;10.7668;A -3000;CTCF;10.5441;A -2000;CTCF;10.8635;A -1000;CTCF;8.45751;A 0;CTCF;8.50316;A 1000;CTCF;10.9143;A 2000;CTCF;10.7022;A 3000;CTCF;10.4101;A 4000;CTCF;10.5757;A -5000;H3K27ac;8.71298;B -4000;H3K27ac;8.43246;B -3000;H3K27ac;8.25497;B -2000;H3K27ac;7.16265;B -1000;H3K27ac;3.55341;B 0;H3K27ac;3.5503;B 1000;H3K27ac;7.07502;B 2000;H3K27ac;8.24328;B 3000;H3K27ac;8.43869;B 4000;H3K27ac;8.48877;B -5000;CTCF;10.6913;B -4000;CTCF;10.7668;B -3000;CTCF;10.5441;B -2000;CTCF;10.8635;B -1000;CTCF;8.45751;B 0;CTCF;8.50316;B 1000;CTCF;10.9143;B 2000;CTCF;10.7022;B 3000;CTCF;10.4101;B 4000;CTCF;10.5757;B"profile_text <- read.table(text=profile, header=T, quote="",sep=";") # tab鍵分割,每列不加引號 write.table(profile_text, file="line_data_melt.xls", sep="\t", row.names=T, col.names=T,quote=F) # 如果看著第一行少了ID列不爽,可以填補下 system("sed -i '1 s/^/ID\t/' line_data_melt.xls")使用正常矩陣默認參數繪制個線圖
# -f: 指定輸入的矩陣文件,第一列為行名字,第一行為header列數不限,列名字不限;行數不限,行名字默認為文本 # -A FALSE: 指定行名為數字 sp_lines.sh -f line_data.xls -A FALSE # -l: 設定圖例的順序 # -o TRUE: 局部擬合獲得平滑曲線 # -A FALSE: 指定行名為數字 # -P: 設置legend位置,相對于原點的坐標 # -x, -y指定橫縱軸標記 sp_lines.sh -f line_data.xls -l "'CTCF','Enhancer','polII','H3K4me3','H3K27ac'" -P 'c(0.8,0.3)' -o TRUE -A FALSE -x 'Up and down 5 kb of TSS' -y 'Relative density' # -A FALSE: 指定行名為數字 # -V 'c(-1000, 500)': 設置垂線的位置 # -D: 設置垂線的文本標記,參數為引號引起來的vector,注意引號的嵌套 # -I: 設置橫軸的標記的位置 # -b: 設置橫軸標記的文字 sp_lines.sh -f line_data.xls -A FALSE -V 'c(-1000,500)' -D "c('+1 kb','-0.5 kb')" -I "c(-5000,0,5000)" -b "c('-5 kb', 'TSS', '+5 kb')"使用melted矩陣默認參數繪制個線圖 (除需要改變文件格式,指定-m TRUE, -a xvariable外其它與正常矩陣一樣)
# -f: 指定輸入文件 # -m TRUE: 指定輸入的矩陣為melted format, 三列,第一列為Pos (給-a) # 第二列為variable (給-H,-H默認即為variable) # 第三列為value,名字不可修改 # -A FALSE: 指定行名為數字 # -P 'c(0.8,0.2)': 設置legend位置,相對于原點的坐標 sp_lines.sh -f line_data_melt.xls -a Pos -m TRUE -A FALSE -P 'c(0.8,0.2)'完整的圖
# -C: 自定義線的顏色 sp_lines.sh -f line_data_melt.xls -a Pos -m TRUE -A FALSE -P 'c(0.8,0.2)' -o TRUE -V 'c(-1000,500)' -D "c('+1 kb','-0.5 kb')" -I "c(-5000,0,4000)" -b "c('-5 kb', 'TSS', '+4 kb')" -x 'Up 5 kb and down 4 kb of TSS' -y 'Relative density' -C "'pink', 'blue'"參數中最需要注意的是引號的使用:
- 外層引號與內層引號不能相同
- 凡參數值中包括了空格,括號,逗號等都用引號括起來作為一個整體。
完整參數列表如下:
ct@ehbio:~ $sp_lines.sh***CREATED BY Chen Tong (chentong_biology@163.com)***Usage:/MPATHB/self/s-plot/sp_lines.sh optionsFunction:This script is used to draw a line or multiple lines using ggplot2. You can specify whether or not smooth your line or lines.Two types of input files are supported, normal matrix or melted matrix format. Column separator for both types of input files is **tab**. Here is an example of normal matrix format. The first column will be treated as X-axis variables and other columns represents each type of lines. The number of columns is unlimited and names of columns is unlimited.**Set** column is not needed. If given, <facet_plot> (multiple plots in one page) could be displayed. ------------------------------------------------------------ Pos H3K27ac CTCF Enhancer H3K4me3 polII -5000 8.71298 10.69130 11.7359 10.02510 8.26866 -4000 8.43246 10.76680 11.8442 9.76927 7.78358 -3000 8.25497 10.54410 12.2470 9.40346 6.96859 -2000 7.16265 10.86350 12.6889 8.35070 4.84365 -1000 3.55341 8.45751 12.8372 4.84680 1.26110 0 3.55030 8.50316 13.4152 5.17401 1.50022 1000 7.07502 10.91430 12.3588 8.13909 4.88096 2000 8.24328 10.70220 12.3888 9.47255 7.67968 3000 8.43869 10.41010 11.9760 9.80665 7.94148 4000 8.48877 10.57570 11.6562 9.71986 8.17849 ------------------------------------------------------------------With SET------------------------------------------ Pos H3K27ac CTCF Enhancer H3K4me3 polII Set -5000 8.71298 10.69130 11.7359 10.02510 8.26866 1 -4000 8.43246 10.76680 11.8442 9.76927 7.78358 1 -3000 8.25497 10.54410 12.2470 9.40346 6.96859 1 -2000 7.16265 10.86350 12.6889 8.35070 4.84365 1 -1000 3.55341 8.45751 12.8372 4.84680 1.26110 1 0 3.55030 8.50316 13.4152 5.17401 1.50022 1 1000 7.07502 10.91430 12.3588 8.13909 4.88096 1 2000 8.24328 10.70220 12.3888 9.47255 7.67968 1 3000 8.43869 10.41010 11.9760 9.80665 7.94148 1 4000 8.48877 10.57570 11.6562 9.71986 8.17849 1 -5000 8.71298 10.69130 11.7359 10.02510 8.26866 2 -4000 8.43246 10.76680 11.8442 9.76927 7.78358 2 -3000 8.25497 10.54410 12.2470 9.40346 6.96859 2 -2000 7.16265 10.86350 12.6889 8.35070 4.84365 2 -1000 3.55341 8.45751 12.8372 4.84680 1.26110 2 0 3.55030 8.50316 13.4152 5.17401 1.50022 2 1000 7.07502 10.91430 12.3588 8.13909 4.88096 2 2000 8.24328 10.70220 12.3888 9.47255 7.67968 2 3000 8.43869 10.41010 11.9760 9.80665 7.94148 2 4000 8.48877 10.57570 11.6562 9.71986 8.17849 2 -------------------------------------------------------------For matrix format, example command lines include:* Attribute of X-axis value (first column of matrix) is <number>s-plot lines -f matrix.file -A FALSE* Attribute of X-axis value (first column of matrix) is <text>s-plot lines -f matrix.file * Attribute of X-axis value (first column of matrix) is numbers, change legned order (default alphabet order)s-plot lines -f matrix.file -l "'polII', 'CTCF', 'Enhancer', 'H3K27ac', 'H3K4me3'"* Attribute of X-axis value (first column of matrix) is numbers, change legned order (default alphabet order), smooth lines to look better (Pay attention to whether this will change the data trend)s-plot lines -f matrix.file -l "'polII', 'CTCF', 'Enhancer', 'H3K27ac', 'H3K4me3'" -o TRUE* Attribute of X-axis value (first column of matrix) is numbers, with <Set> (Set is column name) columns-plot lines -f matrix.file -F "+facet_grid(Set ~ ., scale='free_y')"FILEFORMAT when -m is true #The name "value" shoud **not** be altered. #variable can be altered using -H #Actually this format is the melted result of last format. -------------------------------------------------------------- Pos variable value -5000 H3K27ac 8.71298 -4000 H3K27ac 8.43246 -3000 H3K27ac 8.25497 -2000 H3K27ac 7.16265 -1000 H3K27ac 3.55341 0 H3K27ac 3.55030 1000 H3K27ac 7.07502 2000 H3K27ac 8.24328 3000 H3K27ac 8.43869 4000 H3K27ac 8.48877 -5000 CTCF 10.69130 -4000 CTCF 10.76680 -3000 CTCF 10.54410 -2000 CTCF 10.86350 -1000 CTCF 8.45751 0 CTCF 8.50316 1000 CTCF 10.91430 2000 CTCF 10.70220 3000 CTCF 10.41010 4000 CTCF 10.57570 -------------------------------------------------------------* Attribute of X-axis value (melt format) is <number>s-plot lines -f matrix.file -m TRUE -a Pos -A FALSE* Attribute of X-axis value (first column of matrix) is <text>s-plot lines -f matrix.file -m TRUE -a Pos* If the name of the second column is <type> not <variable>, one should specify with <-H>. s-plot lines -f matrix.file -A FALSE -m TRUE -a Pos -H type* Attribute of X-axis value (first column of matrix) is numbers, change legned order (default alphabet order)s-plot lines -f matrix.file -m TRUE -a Pos -l "'polII', 'CTCF', 'Enhancer', 'H3K27ac', 'H3K4me3'"* Attribute of X-axis value (first column of matrix) is numbers, change legned order (default alphabet order), smooth lines to look better (Pay attention to whether this will change the data trend)s-plot lines -f matrix.file -m TRUE -a Pos -l "'polII', 'CTCF', 'Enhancer', 'H3K27ac', 'H3K4me3'" -o TRUE* Attribute of X-axis value (first column of matrix) is numbers, with <Set> (Set is column name) columns-plot lines -f matrix.file -F "+facet_grid(Set ~ ., scale='free_y')"OPTIONS:-f Data file (with header line, the first column would be be treated as rownames fornormal matrix. No rownames for melted format. Columns are tab seperated)[NECESSARY]-m When true, it will skip melt preprocesses. But the format must bethe same as listed before.[Default FALSE, accept TRUE]-a Name for x-axis variable[Only needed when <-m> is <TRUE>. For the melted data, 'Pos' should be given here. For normal matrix, default the first column will be used,program will assign an value 'xvariable' to represent it.]]-A Are x-axis variables numbers.[Default <TRUE>, meaning X-axis label is <text>.<FALSE> means X-axis label is <numerical>.]-H Name for legend variable.[Default variable, this should only be set when -m is TRUE]-J Name for color variable.[Default same as -H, this should only be set when -m is TRUE]-l Set orders of legend variable.[Default column order for normal matrix, accept a string like"'CTCF','H3K27ac','Enhancer'" to set your own order. Pay attention to the usage of two types of quotes. ***When -m is TRUE, default order would be alphabet order.********* ]-P Legend position[Default right. Accepttop, bottom, left, none, or 'c(0.08,0.8)'.]-L Levels for x-axis variable, suitable when x-axis is not treated as numerical. [Default the order of first column for normal matrix. Accept a string like "'g','a','j','x','s','c','o','u'" to set your own oder.This will only be considered when -A is TRUE.***When -m is used, this default order would be alphabet order.********* ]-o Smooth lines or not.[Default FALSE means no smooth. Accept TRUE to smooth lines.]-O The smooth method you want to use.[smoothing method (function) to use, eg. lm, glm, gam, loess,rlm.For datasets with n < 1000 default is 'loess'. For datasets with 1000 or more observations defaults to 'gam'.]-V Add vertical lines.[Default FALSE, accept a series ofnumbers in following format "c(1,2,3,4,5)" or otherR code that can generate a vector.]-D Add labels to vlines.[Default same as -V.Accept a series of numbers in following format "c(1,2,3,4,5)" or other R codethat can generate a vector as labels.Or one can give '1' to disallow labels]-j Add horizontal lines.[Default FALSE, accept a series ofnumbers in following format "c(1,2,3,4,5)" or otherR code that can generate a vector]-d Add labels to hline.[Default same as -jAccept a series of numbers in following format "c(1,2,3,4,5)" or other R codethat can generate a vector as labels.Or one can give '1' to disallow labels]-I Manually set the position of xtics.[Default FALSE, accept a series ofnumbers in following format "c(1,2,3,4,5)" or other R codethat can generate a vector to set the position of xtics]-b Manually set the value of xtics when -I is specified.[Default the content of -I when -I is specified, accept a series of numbers in following format "c(1,2,3,4,5)" or other R codethat can generate a vector to set the position of xtics]-X Display xtics. [Default TRUE]-Y Display ytics. [Default TRUE]-R Rotation angle for x-axis labels (anti clockwise)[Default 0]-B line size. [Default 1. Accept a number.]-t Title of picture[Default empty title]-x xlab of picture[Default empty xlab]-y ylab of picture[Default empty ylab]-c Manually set colors for each line.[Default FALSE, meaning using ggplot2 default.]-C Color for each line.When -c is TRUE, one has two options:1. Supplying a function to generate colors, like "rainbow(11)" or "rainbow(11, alpha=0.6)", rainbow is an R color palletes, 11 is the number of colors you want to get, 0.6 is the alpha value.The R palletes include <heat.colors>, <terrain.colors>,<topo.colors>, <cm.colors>.2. Supplying a list of colors in given format, the number of colors should be equal to the number ofbars like "'red','pink','blue','cyan','green','yellow'" or"rgb(255/255,0/255,0/255),rgb(255/255,0/255,255/255),rgb(0/255,0/255,255/255),rgb(0/255,255/255,255/255),rgb(0/255,255/255,0/255),rgb(255/255,255/255,0/255)"One can use R fucntion <colors()> to list all available colors.-s Scale y axis[Default null. Accept TRUE. This function is depleted. But if the supplied number after -S is not 0, this parameter will be set to TRUE]-F The formula for facets.[Default no facets, "+facet_grid(level ~ .)" means divide by levels of 'level' vertically."+facet_grid(. ~ level)" means divide by levels of 'level' horizontally."+facet_grid(lev1 ~ lev2)" means divide by lev1 vertically and lev2 horizontally."+facet_wrap(~level, ncol=2)" means wrap horizontally with 2 columns.#Pay attention to the single quote for parameters in function for scale.Example: "+facet_wrap(~Size,ncol=6,scale='free')"Example: "+facet_grid(Size ~ .,scale='free_y')"]-G If facet is given, you may want to specifize the order ofvariable in your facet, default alphabetical order.[Accept sth like (one level one sentence, separate by';') 'data$size <- factor(data$size, levels=c("l1", "l2",...,"l10"), ordered=T)' ]-v If scale is TRUE, give the following 'scale_y_log10()'[default], 'coord_trans(y="log10")', or other legal command for ggplot2 or simply 'log2'.]-S A number to add if scale is used.[Default 0. If a non-zero number is given, -s would be set to TRUE.] -p Other legal R codes for gggplot2 could be given here.[Begin with '+' ]-w The width of output picture (cm).[Default 20]-u The height of output picture (cm).[Default 12] -E The type of output figures.[Default pdf, accepteps/ps, tex (pictex), png, jpeg, tiff, bmp, svg and wmf)]-r The resolution of output picture.[Default 300 ppi]-z Is there a header. Must be TRUE. [Default TRUE]-e Execute or not[Default TRUE]-i Install depended packages[Default FALSE]為了推廣,也為了激起大家的熱情,如果想要sp_lines.sh腳本的,還需要勞煩大家動動手,轉發此文章到朋友圈,并留言索取。
也希望大家能一起開發,完善功能。
Reference
- http://blog.genesino.com//2017/06/R-Rstudio
總結
- 上一篇: FCPX插件:Color Titles动
- 下一篇: android 滚动条自定义样式,ISc