您好,登錄后才能下訂單哦!
本文小編為大家詳細(xì)介紹“R語(yǔ)言99%閾值置信區(qū)間是怎么計(jì)算的”,內(nèi)容詳細(xì),步驟清晰,細(xì)節(jié)處理妥當(dāng),希望這篇“R語(yǔ)言99%閾值置信區(qū)間是怎么計(jì)算的”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來(lái)學(xué)習(xí)新知識(shí)吧。
R語(yǔ)言代碼:
###########genotype############################# genotype<-function(){ count<-0 if (population_structure=="RIL"){ x<-runif(1) if (x<=0.5){ count<-1 }else{ count<-0 } }else{ for(i in 1:2){ x<-runif(1) if (x<=0.5){ number<-0.5 }else{ number<-0 } if(number == 0.5){ count<- count+0.5 } } } return(count) } ############################################################ ###########caluclate of genotype ratio######################### individuals_genotype<-function(number_of_total_individuals){ ratio_of_genotype<-c() for(i in 1:number_of_total_individuals){ ratio_of_genotype<-c(ratio_of_genotype,genotype()) } return(mean(ratio_of_genotype)) } ############################################################ ###########SNP_index_caluclation######################### snp_index<-function(read_depth,ratio_of_genotype_in_the_population){ x1<-rbinom(1,read_depth,ratio_of_genotype_in_the_population) return(x1/read_depth) } ############################################################ #################################### #################################### Arg<-commandArgs(TRUE) ###########input############################################### population_structure<-"F2" individual_analysis<- c(Arg[1]) reprication<-c(Arg[2]) filter_value<-c(Arg[3]) depth_analysis<-c(1:300) ###########input############################################### for (key_individual in individual_analysis){ individual_number<-key_individual depth_data<-c() p_h_data_95<-c() p_h_data_99<-c() for (key_depth in depth_analysis){ depth_data<-c(depth_data,key_depth) depth<-key_depth sum_snp_index<-c() for(i in 1:reprication){ ##########gene_frequency###################### ratio_of_genotype_in_the_population<-individuals_genotype(key_individual) a_snp_index<-snp_index(key_depth,ratio_of_genotype_in_the_population) if(a_snp_index >= filter_value){ sum_snp_index<-c(sum_snp_index,a_snp_index) } ##########gene_frequency###################### } order_sum_snp_index<-sort(sum_snp_index) length_sum_snp_index<-length(sum_snp_index) ##########snp_index_probabirity_0.05###################### snp_cutoff_up_0.95<-order_sum_snp_index[ceiling(0.95*length_sum_snp_index)] p_h_data_95<-c(p_h_data_95,snp_cutoff_up_0.95) ##########snp_index_probabirity_0.05###################### ##########snp_index_probabirity_0.01###################### if (ceiling(0.99*length_sum_snp_index)<length_sum_snp_index){ snp_cutoff_up_0.99<-order_sum_snp_index[ceiling(0.99*length_sum_snp_index)] }else{ snp_cutoff_up_0.99<-order_sum_snp_index[length_sum_snp_index] } p_h_data_99<-c(p_h_data_99,snp_cutoff_up_0.99) ##########snp_index_probabirity_0.01###################### } FINAL_DATA<-data.frame(DEPTH=depth_data,P_H_95=p_h_data_95,P_H_99=p_h_data_99) table_name<-paste("./",individual_number,sep="") table_name<-paste(table_name,"individuals.txt",sep="") write.table(FINAL_DATA,table_name,sep="\t", quote=F, append=F,row.name=F) }
讀到這里,這篇“R語(yǔ)言99%閾值置信區(qū)間是怎么計(jì)算的”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識(shí)點(diǎn)還需要大家自己動(dòng)手實(shí)踐使用過(guò)才能領(lǐng)會(huì),如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。