knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Author: Jiaxuan Wang :pencil:
The goal of xbox is created with some script writed in my spare time. on the other side, the R packages is created just for myself. My names is Wang Jiaxuan, a chinese name. the packages named "xbox" because the tail name is xuan. like xuan's tool box(Why not xtoolbox, or xtbox, No! these are so complex).
with the time flewed, the R packages function will be more and more.
get_df
fix the bug for select the column namesget_mat
for transfer data.frame or tibble to matrixget_tb
add the var
for change the “rownames” to “id”disco
to display the color you choose. It is convenient to choose the one which you like most.vennplot
function for draw venn plot, It's not a simple venn plot , it's a venn plot can change the intersect area represent the intersect number size. also somebody call it area-proportional Venn diagrams.The R packages only can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("wangjiaxuan666/xbox")
Notice, If install failed with the messages
ERROR: dependencies 'KEGGREST', 'qvalue' are not available for package 'xbox' * removing 'C:/R/library/xbox'
You should install R packages KEGGREST
and qvalue
firstly with code:
if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("qvalue") BiocManager::install("KEGGREST")
It's best to update before you start use the package. just because it is constantly updated and add new fucntion within.
devtools::update_packages("xbox")
Firstlrmarkdown::render("README.Rmd")
y, you should library the xbox
R packages.
library(xbox)
add the fucntion 'need_colors' to choose the chinese traditional color palette that disigned by 大东设计. who is a bolger in tiktok(抖音). When I saw his painting, I feel shock for those color's power. So I decide make a R packages to put those color into a color schemes that everyone can use easily. and you can use disco
to display the color you choose. It is convenient to choose the one which you like most.
need_colors("two2") disco("two2") need_colors("nine1",5) disco("nine1",5)
In my disign, for ease of use. I use the 'the number which you want' + 'id' to name the color palette, such as "two1","two2","three1","four1","nine1". Even you forget so simple name, it's doesn't matter. Beacuse you can use the number directly. Now, in a word, it's very convenient!!
need_colors(10) disco(10)
For more details, please see the bolg "R包xbox-增加中国风配色方案", which publiced on WeChat official account.Abego
the first function is col_ttest
, the function is creat for the t.test
in the two column group to test. the output including the pvalue,qvalue.
Notice,the qvalue is the result of the R packages qvalue
.the parameter is defult. I think is adjust pvalue method is bonferroni.
set.seed("20201225") test = matrix(rnorm(20), 2, 10) colnames(test) = paste("Test", 1:10, sep = "") rownames(test) = paste("Gene", 1:2, sep = "") str(col_ttest(data = test,g1 = 1:5,g2 = 6:10))
the t_dat
function is uesed for transpose the data. Notice,it's not the function transpose
in tidyverse
or tidyr
. t_dat
can exchange the column and row. Make the column names become the row names and the row names become the column names. the data is tranpose with the names. it is complex for me to explain it clearly with the English. let's see how does it work.
df = mtcars[1:6,1:6] print(df) print(t_dat(df))
Maybe you have see the NOTICE
that mentioned the R packages hablar
. The hablar
is creat by David Sjoberg. a excellent R packages. You can see its introdution in Github. i use the funtion retype
to help the change and ensure the column type. But I still think we should chect the result again by str()
.
the function is useful the biology. If you have a list of ko number id. But don't know the the name or descrption of the ko ID . You should try the function. I use the keggget
funtion in R packages KEEGREST
which R packages in bioconda. the native function can scrawl the all information form KEGG Database. But I only need the KEGG A Anoation
,KEGG B Anoation
and the KEGG Pathway Anoation
. So the koid_to_pathway
only extract the the information of the pathway description. like thie:
koid_to_pathway("ko04075") #Success depends on the network. #koid <-c("ko00010", "ko00020", "ko00030") #koid_to_pathway(koid)
the simple function! the thing only can be done is change the data.frame to a tibble. I creat it just because of the funtion rownams_to_column
which's names is too long!
The simple example is :
head(cars) head(get_tb(cars))
Not end the sister function get_df
, Which change the tibble to data.frame .
head(mtcars) head(get_df(mtcars))
The get_mat
function is used for tansfer data whatever which type it is to a matrix.
head(get_mat(cars))
The function heatpoint
is created for the desity plot, It can caculate the point density in 2-dimension coordinate or 1D coordinate by the parameter only
. Of course, the Main purpose is the plot a density heatpoint.
points = 5000 x = c(rnorm(points/2)) y = x + rnorm(points/2,sd=0.8) x = sign(x)*abs(x)^1.3 heatpoint(x,y) -> dat_result str(dat_result) #including the three list the plot data head(dat_result$plot.data) # and the result of cor data.frame(dat_result$cor.result) # and the result of lm str(dat_result$lm.result)
You can use the result of heatpoint
to plot by yourself, also can use the the R scription in R packages namesplot
xplot(dat_result)
Draw an area-proportional Venn diagram of 2 or 3 circles change by wangjiaxuan
The original function from bioVenn R packages(https://cran.r-project.org/web/packages/BioVenn/index.html), I improve the data output and delete the output
parameter.
on the next step , I plan to add the ggplot2 on the function which draw venn plot. or change the postion of group title name whcih is on the centre of circle now, very ugly.
This function creates an area-proportional Venn diagram of 2 or 3 circles, based on lists of (biological) identifiers. It requires three parameters: input lists X, Y and Z. For a 2-circle Venn diagram, one of these lists should be left empty. Duplicate identifiers are removed automatically.
When using a BioVenn diagram for a publication, please cite: BioVenn - a web application for the comparison and visualization of biological lists using area-proportional Venn diagrams T. Hulsen, J. de Vlieg and W. Alkema, BMC Genomics 2008, 9 (1): 488
list_x <- c("1007_s_at","1053_at","117_at","121_at","1255_g_at","1294_at") list_y <- c("1255_g_at","1294_at","1316_at","1320_at","1405_i_at") list_z <- c("1007_s_at","1405_i_at","1255_g_at","1431_at","1438_at","1487_at","1494_f_at") biovenn <- vennplot(list_x, list_y, list_z)
This function is to be able to calculate counts in various ranges. It comes with a drawing function. At present, this function is s3 general function, which can automatically identify the input data type and draw.
data = range_count(x = rnorm(100,5)*100,gap = 100,min_num = 0,max_num = 1000) print(data) xplot(data)
devtools::session_info()[["platform"]]
Sys.Date()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.