1.首先加载示例数据:
MCPcounter是一个免疫浸润包
if(!require(MCPcounter))install_github("ebecht/MCPcounter",ref="master", subdir="Source")
library(MCPcounter)
下载不了的同学可以去github本地下载
2.查看一下提供的细胞类型
rownames(MCPcounter.estimate(MCPcounterExampleData))
# [1] "T cells" "CD8 T cells" "Cytotoxic lymphocytes" "NK cells"
# [5] "B lineage" "Monocytic lineage" "Myeloid dendritic cells" "Neutrophils"
# [9] "Endothelial cells" "Fibroblasts"
实际上这些标题是有问题的,因为空格作为分割是不理想的分割方式
3.转换
cell_types <- make.names(rownames(MCPcounter.estimate(MCPcounterExampleData)))
cell_types
# [1] "T.cells" "CD8.T.cells" "Cytotoxic.lymphocytes" "NK.cells"
# [5] "B.lineage" "Monocytic.lineage" "Myeloid.dendritic.cells" "Neutrophils"
# [9] "Endothelial.cells" "Fibroblasts"
这时空格被"."替代
4.当然如果不想用.也可以
gsub(" ","_",rownames(MCPcounter.estimate(MCPcounterExampleData)))
[1] "T_cells" "CD8_T_cells"
[3] "Cytotoxic_lymphocytes" "NK_cells"
[5] "B_lineage" "Monocytic_lineage"
[7] "Myeloid_dendritic_cells" "Neutrophils"
[9] "Endothelial_cells" "Fibroblasts"
实现下划线替换
注意上面的" "里面要敲一个空格才行