Skip to content

Commit

Permalink
first upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Bioinfoplanet committed Jul 13, 2020
1 parent 792edec commit a16d48c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/survival_cut_cox_km.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ point_cut <- function(exprSet_hub,meta){
##' caculate log_rank test p values for genes
##'
##' @inheritParams point_cut
##' @inheritParams t_choose
##' @param cut.point logical , use cut_point or not, if FALSE,use median by defult
##' @param pvalue_cutoff p value cut off ,0.05 by defult
##' @importFrom survival Surv
##' @importFrom survival survdiff
##' @export
Expand Down
12 changes: 7 additions & 5 deletions R/t_choose.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
##' @param genes a vector with some genes
##' @param up_only keep up genes in the result only
##' @param down_only keep down genes in the result only
##' @param pvalue_cutoff p value cut off ,0.05 by defult
##' @export
##' @return a vector with diffrencial expressed genes
##' @author Xiaojie Sun
Expand All @@ -23,7 +24,8 @@
##' \code{\link{geo_download}};\code{\link{draw_volcano}};\code{\link{draw_venn}}


t_choose <- function(genes,exp,group_list,up_only = F,down_only = F){
t_choose <- function(genes,exp,group_list,up_only = F,down_only = F,pvalue_cutoff = 0.05){
if(up_only&down_only)stop("please change neither up_only or down_only to FALSE")
table(genes %in% rownames(exp))
exp_small = exp[rownames(exp) %in% genes,]
dat = data.frame(t(exp_small))
Expand All @@ -32,23 +34,23 @@ t_choose <- function(genes,exp,group_list,up_only = F,down_only = F){
t.test(dat[,i] ~group_list)$p.value
})
names(p_v) = colnames(dat)[-ncol(dat)]
table(p_v<0.05)
exp_genes = names(p_v[p_v < 0.05])
table(p_v<pvalue_cutoff)
exp_genes = names(p_v[p_v < pvalue_cutoff])
if(up_only){
es_up <- sapply(1:(ncol(dat)-1), function(i){
tmp = t.test(dat[,i] ~group_list)
k = tmp$estimate[2]-tmp$estimate[1] >0
return(k)
})
up_genes = genes[p_v <0.05 & es_up]
up_genes = genes[p_v <pvalue_cutoff & es_up]
return(up_genes)
}else if(down_only){
es_down <- sapply(1:(ncol(dat)-1), function(i){
tmp = t.test(dat[,i] ~group_list)
k = tmp$estimate[2]-tmp$estimate[1] <0
return(k)
})
down_genes = genes[p_v <0.05 & es_down]
down_genes = genes[p_v <pvalue_cutoff & es_down]
return(down_genes)
}else{
return(exp_genes)
Expand Down
11 changes: 10 additions & 1 deletion man/t_choose.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a16d48c

Please sign in to comment.