如何按照热图中的顺序输出表达量文件

• A+ #########分割线##########

library(pheatmap)

result <- pheatmap(exp,scale="row") # 保存热图的绘图关键数据## 从热图中提取样本顺序的编号和样本名

col_oder=result$tree_col$order # 保存热图列顺序（序号）

row_oder=result$tree_row$order # 保存热图行顺序（序号）

cn_new <- colnames(exp)[col_oder] # 保存热图的列名

rn_new <- rownames(exp)[row_oder] # 保存热图的行名

## 生成两个新的与原来的表达量总表长宽相同的数据框（暂时都填写0）

new_exp <- matrix(rep(0,ncol(exp)*nrow(exp)),nrow = nrow(exp),ncol = ncol(exp))

out <- matrix(rep(0,ncol(exp)*nrow(exp)),nrow = nrow(exp),ncol = ncol(exp))

## 将表达量数据读入数据框new_exp,行顺序已经按照热图的顺序重排

for (i in 1:ncol(exp)){

new_exp[,i]=exp[,i][row_oder]

}

## 将表达量数据读入数据框out,列顺序已经进一步按照热图的顺序重排

for (i in 1:ncol(exp)){

out[,i]= new_exp[,col_oder[ i ]]

}

# 将热图的行名和列名导入到排序后的表达量总表中

rownames(out)=rn_new

colnames(out)=cn_new

write.table(out,"hp_exp.txt",sep="t") #输出重排后的表达量表
{"ft_lang_label":"__label__zh","ft_lang_prob":0.7333761,"math_prob":0.98537993,"size":1178,"snap":"2019-43-2019-47","text_gpt3_token_len":766,"char_repetition_ratio":0.12010221,"word_repetition_ratio":0.054054055,"special_character_ratio":0.2631579,"punctuation_ratio":0.15384616,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99560905,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-20T14:42:59Z\",\"WARC-Record-ID\":\"<urn:uuid:4df1c36f-e735-48af-a82e-969e445d2400>\",\"Content-Length\":\"57846\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:635849b4-40ad-4497-8e95-0dd5d19f3dd8>\",\"WARC-Concurrent-To\":\"<urn:uuid:fcc60a6b-741c-4bdf-8892-50afa5127755>\",\"WARC-IP-Address\":\"172.105.221.157\",\"WARC-Target-URI\":\"https://www.plob.org/article/14840.html\",\"WARC-Payload-Digest\":\"sha1:I3KYLVIZJMJ5C3V2L6VSB7AAJWDFMEN3\",\"WARC-Block-Digest\":\"sha1:BROIPNOR6X5BWT7OHIO2WHIEKWRCUKEW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986710773.68_warc_CC-MAIN-20191020132840-20191020160340-00196.warc.gz\"}"}