R语言 将基于匹配的行名替换为另一个嵌套框架的相应列的子字符串[已关闭]

jxct1oxe  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(102)

已关闭,此问题需要details or clarity,目前不接受回答。
**想要改进此问题吗?**通过editing this post添加详细信息并澄清问题。

9天前关闭
Improve this question
我想用相应的maf$Tumor_Sample_Barcode值替换rownames(clin.info)
如果clin.info的行名称与maf$Tumor_Sample_Barcode中的子字符串匹配,则将行名称(clin.info)替换为相应的maf$Tumor_Sample_Barcode值。

substring.colnames <- sub("^(TCGA[^.]+\\.[^.]+\\.[^.]+)\\..*", "\\1", maf$Tumor_Sample_Barcode)
filtered.maf <- subset(maf, grepl("^TCGA", substring.colnames))
rownames(clin.info)[1:length(filtered.maf)] <- unique(filtered.maf$Tumor_Sample_Barcode)

字符串
回溯:

Warning message:
In rownames(clin.info)[1:length(filtered.maf)] <- unique(filtered.maf$Tumor_Sample_Barcode) :
  number of items to replace is not a multiple of replacement length


输入:

> dput(maf)
structure(list(Hugo_Symbol = c("TKT", "LRRC58", "GOLGB1", "PDIA5", 
"GFM1", "ATP8A1", "UGT2A1", "PCDH10", "MAML3", "ASIC5", "SRPK1", 
"SRPK1", "KLC4", "PKHD1", "CD164", "MIOS", "MAGI2", "MCPH1", 
"WWP1", "PARP10", "DAPK1", "LMX1B", "ADAMTSL2", "SEC16A", "ZMYND19", 
"FRMD4A", "PCDH15", "KIFBP", "MUC6", "OR4C13", "CASP4", "NCAPD3", 
"CLEC1A", "ITPR2", "BCDIN3D", "NABP2", "NXPH4", "KIF5A", "GPN3", 
"TBC1D4", "CHAMP1", "NRDE2", "MAPK6", "DET1", "MPG", "CRAMP1", 
"JPT2", "RPGRIP1L", "FCSK", "WDR81", "SGSM2", "SGSM2", "MYO18A", 
"TMEM106A", "ACSF2", "MED13", "PSMC5", "TRIM65", "ABHD3", "GZMM", 
"CD209", "PPAN", "KANK2", "ZNF30", "COX7A1", "DPF1", "FIZ1", 
"SNRPB2", "SYS1", "CDH22", "MYT1", "TIAM1", "RANBP1", "IGLL1", 
"NF2", "SGSM3", "ANOS1", "GPR173", "PAK3", "IPO13", "SLC30A1", 
"RRP15", "GALNT2", "RGS7", "CHMP3", "CHRNA1", "SLC40A1", "HECW2", 
"ABCB6", "SEC13", "MLH1", "XYLB", "SLC38A3", "ABHD10", "EEFSEC", 
"ZMAT3", "KIAA1109", "CLPTM1L", "MOCS2", "ARHGEF28", "SEMA6A", 
"SLC25A48", "SLC25A48", "HSPA9", "RANBP17", "SLC17A4", "MUC21", 
"MCM3", "COL19A1", "FERD3L", "SEMA3D", "KIAA1549", "ATP6V0E2", 
"NEIL2", "LYN", "GEM", "RAD54B", "OR13J1", "SECISBP2", "RAD23B", 
"RABGAP1", "MLLT10", "ANXA11", "PSTK", "SLC43A1", "INCENP", "EED", 
"SLC35F2", "SIDT2", "SLC6A12", "KDM5A", "TIGAR", "GPR162", "ITPR2", 
"DIP2B", "ESPL1", "RDH5", "GLIPR1L2", "CUL4A", "LAMP1", "NEMF", 
"DLGAP5", "DISP2", "MYO5A", "PKD1", "SRRM2", "PRKCB", "ZNF48", 
"ZC3H18", "SAT2", "MRO", "LINGO3", "ZNF557", "CACNA1A", "ZNF461", 
"RYR1", "ERCC2", "BAX", "ZNF816-ZNF321P", "NLRP9", "MZF1", "CPXM1", 
"HUNK", "TTC3", "MICAL3", "MTMR3", "POLR2F", "KDELR3", "PADI6", 
"NT5C1A", "TGFBR3", "GLMN", "ITLN2", "NUF2", "ABL2", "TRMT1L", 
"CACNA1S", "FAM89A", "ASAP2", "NBAS", "USP34", "USP34", "TTC21B", 
"PIKFYVE", "SETD2", "TBC1D23", "PCCB", "WWTR1", "ZNF141", "FGFRL1", 
"SLC12A7", "FAM172A", "TNRC18", "RNF216", "TRIP6", "SSPOP", "INTS8", 
"DSCC1", "FAM91A1", "MROH6", "RABL6", "PTGDS", "ZNF248", "CCAR1", 
"GPR26", "PTDSS2", "IRF7", "MUC5AC", "OR51B4", "TTC17", "CDC42BPG", 
"TIMM8B", "WNK1", "SCNN1A", "ITGA5", "UBE3B", "ATP7B", "RIPK3", 
"SYT16", "SYT16", "AHNAK2", "TRPM1", "VPS39", "DUOXA1", "PLEKHO2", 
"MYO9A", "SLC28A1", "AKAP13", "TMC5", "RBBP6", "BCKDK", "SRR", 
"ZNF594", "CASC3", "GRN", "ESCO1", "ZNF77", "NFIC", "CYP2A13", 
"CYP2A13", "HNRNPUL1", "BCAM", "POLR1G", "AP2A1", "USP29", "USP29", 
"VN1R1", "ZNF341", "ADNP", "MIR99AHG", "ABCG1", "SMARCB1", "VSIG4", 
"CHD5", "COL16A1", "GCLM", "ATXN7L2", "TRIM33", "VTCN1", "CCT3", 
"SPTA1", "C1orf74", "USH2A", "SMYD1", "DDX18", "LRP2", "TTN", 
"CALCRL", "DNAH7", "ITM2C", "SEC13", "CTNNB1", "DAG1", "CACNA1D", 
"TASOR", "OR5H6", "ARGFX", "AC131160.1", "SLC2A9", "FAT4", "CDH9", 
"HMGCS1", "SETD9", "POU5F2", "CEP120", "NPM1", "ABCF1", "RPL10A", 
"SAYSD1", "GPRC6A", "DNAJC30", "COPS6", "DUS4L-BCAP29", "AGAP3", 
"C8orf86", "CYHR1", "TTC16", "TSC1", "SVIL", "STOX1", "BMPR1A", 
"MICAL2", "PHLDB1", "AEBP2", "KRT73", "MON2", "RNFT2", "HIP1R", 
"SACS", "MIPEP", "RNF17", "GPR12", "MYH7", "ALDH6A1", "IGHD2-21", 
"RYR3", "RYR3", "EIF2AK4", "LRRC57", "EPB42", "ZSCAN10", "VWA3A", 
"HSF4", "MINK1", "SLC2A4", "SHMT1", "EFCAB5", "EFCAB5", "MLLT6", 
"STAT3", "STAT3", "EFTUD2", "NFE2L1", "CLTC", "ABCA10", "AFMID", 
"DCC", "TNFRSF11A", "ZNF557", "KEAP1", "IL17RA", "MICAL3", "PPIL2", 
"MN1", "EMID1", "KDM6A", "C1GALT1C1", "ACAP3", "GJB3", "MUTYH", 
"CCDC17", "CYP2J2", "IL12RB2", "ABCD3", "CSDE1", "NBPF11", "FCRL4", 
"MYO7B", "LRTM1", "KALRN", "IFT122", "SEL1L3", "TMPRSS11F", "FNIP2", 
"RASGRF2", "RAPGEF6", "PCDHB3", "KIFC1", "TULP4", "TNRC18", "CALCR", 
"SDHAF3", "POP7", "RELN", "SND1", "PLXNA4", "ZNF425", "SSPOP", 
"GIMAP1", "ADGRA2", "NOL6", "PRKACG", "RALGDS", "OPTN", "CUBN", 
"JMJD1C", "CDH23", "ECD", "PPFIBP2", "NUP160", "ZBTB3", "SLC4A8", 
"USP15", "ANKS1B", "POLE", "SACS", "SACS", "CDK8", "ARHGEF40", 
"PPP2R3C", "GABRB3", "CHP1", "DUT", "ZNF280D", "MRPL46", "LRRK1", 
"PPL", "C16orf72", "ABCC12", "SLC6A2", "WWP2", "CHST5", "DPEP1", 
"SCARF1", "MYH10", "MYH2", "PLEKHH3", "DHX8", "GRIN2C", "DSG4", 
"FZR1", "PLIN4", "TNPO2", "NOTCH3", "ZNF536", "PSG9", "MKKS", 
"ISM1", "PLXNB2", "MAGIX", "GABRQ", "MTOR", "CSMD2", "MTF1", 
"RIMS3", "LRRC42", "SLC25A44", "OR6K6", "HMCN1", "PPP1R15B", 
"USH2A", "OBSCN", "PKDCC", "MSH6", "ZEB2", "IKZF2", "DNAH1", 
"LRIG1", "EPHA3", "ATR", "CP", "ABCC5", "SEC31A", "GRID2", "ZCCHC10", 
"DDX41", "COL12A1", "MMS22L", "SERINC1", "SP4", "MYO1G", "ARMC1", 
"TMC1", "NELFB", "EPC1", "MBL2", "CCDC86", "RNASEH2C", "PANX1", 
"LPCAT3", "SCN8A", "KRT84", "C12orf29", "RPH3A", "FREM2", "RAB15", 
"PLEKHH1", "EML5", "WDR20", "BAHD1", "UBR1", "SLC24A5", "REC114", 
"POLG", "CLDN9", "ANKS4B", "COG8", "ZNF469", "SLC52A1", "CHRNB1", 
"SLC35G6", "UTP6", "MED1", "CLTC", "SLC25A19", "RNF213", "CC2D1A", 
"GRAMD1A", "CYP2A6", "ZNF235", "ZNF154"), Tumor_Sample_Barcode = c("TCGA-2Z-A9J1-01A-11D-A381-01", 
"TCGA-2Z-A9J1-01A-11D-A381-01", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-2K-A9WE-01A-11D-A381-01", 
"TCGA-2K-A9WE-01A-11D-A381-01", "TCGA-2K-A9WE-01A-11D-A381-01", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-SX-A7SL-01A-11D-A34Z-10", "TCGA-SX-A7SL-01A-11D-A34Z-10", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-2K-A9WE-01A-11D-A381-01", 
"TCGA-2K-A9WE-01A-11D-A381-01", "TCGA-2K-A9WE-01A-11D-A381-01", 
"TCGA-2K-A9WE-01A-11D-A381-01", "TCGA-2K-A9WE-01A-11D-A381-01", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-GL-8500-01A-11D-2396-08", 
"TCGA-GL-8500-01A-11D-2396-08", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9JU-01A-11D-A42J-10", "TCGA-5P-A9JU-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-5P-A9KE-01A-11D-A42J-10", "TCGA-5P-A9KE-01A-11D-A42J-10", 
"TCGA-2Z-A9J1-01A-11D-A381-01", "TCGA-2Z-A9J1-01A-11D-A381-01", 
"TCGA-2Z-A9J1-01A-11D-A381-01", "TCGA-2Z-A9J1-01A-11D-A381-01", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-P4-AAVL-01A-11D-A42J-10", "TCGA-P4-AAVL-01A-11D-A42J-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-2Z-A9J2-01A-11D-A381-01", 
"TCGA-2Z-A9J2-01A-11D-A381-01", "TCGA-2Z-A9J2-01A-11D-A381-01", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10", 
"TCGA-GL-A4EM-01A-11D-A25F-10", "TCGA-GL-A4EM-01A-11D-A25F-10"
)), row.names = 500:1000, class = "data.frame")

> dput(rownames(clin.info))
c("TCGA.2K.A9WE.01", "TCGA.2Z.A9J1.01", "TCGA.2Z.A9J3.01", "TCGA.2Z.A9J6.01", 
"TCGA.2Z.A9J7.01", "TCGA.2Z.A9J8.01", "TCGA.2Z.A9JI.01", "TCGA.2Z.A9JJ.01", 
"TCGA.2Z.A9JQ.01", "TCGA.4A.A93W.01", "TCGA.4A.A93X.01", "TCGA.5P.A9JU.01", 
"TCGA.A4.7583.01", "TCGA.A4.7584.01", "TCGA.A4.7915.01", "TCGA.A4.7996.01", 
"TCGA.A4.7997.01", "TCGA.A4.8098.01", "TCGA.A4.8311.01", "TCGA.A4.8517.01", 
"TCGA.A4.8630.01", "TCGA.A4.A57E.01", "TCGA.AL.7173.01", "TCGA.AL.A5DJ.01", 
"TCGA.B1.5398.01", "TCGA.B1.7332.01", "TCGA.B1.A47M.01", "TCGA.B1.A47N.01", 
"TCGA.B1.A47O.01", "TCGA.B1.A654.01", "TCGA.B1.A657.01", "TCGA.B3.A6W5.01", 
"TCGA.B9.5155.01", "TCGA.B9.A44B.01", "TCGA.B9.A5W7.01", "TCGA.B9.A5W8.01", 
"TCGA.B9.A5W9.01", "TCGA.B9.A69E.01", "TCGA.B9.A8YH.01", "TCGA.BQ.5875.01", 
"TCGA.BQ.5877.01", "TCGA.BQ.5878.01", "TCGA.BQ.5879.01", "TCGA.BQ.5881.01", 
"TCGA.BQ.5885.01", "TCGA.BQ.5887.01", "TCGA.BQ.5889.01", "TCGA.BQ.5890.01", 
"TCGA.BQ.5891.01", "TCGA.BQ.5892.01", "TCGA.BQ.5893.01", "TCGA.BQ.7049.01", 
"TCGA.BQ.7050.01", "TCGA.BQ.7051.01", "TCGA.BQ.7053.01", "TCGA.BQ.7055.01", 
"TCGA.BQ.7056.01", "TCGA.BQ.7060.01", "TCGA.BQ.7062.01", "TCGA.DW.5560.01", 
"TCGA.DW.5561.01", "TCGA.DW.7834.01", "TCGA.DW.7837.01", "TCGA.DW.7838.01", 
"TCGA.DW.7841.01", "TCGA.DW.7842.01", "TCGA.DZ.6131.01", "TCGA.DZ.6133.01", 
"TCGA.EV.5902.01", "TCGA.EV.5903.01", "TCGA.F9.A4JJ.01", "TCGA.F9.A7Q0.01", 
"TCGA.F9.A7VF.01", "TCGA.F9.A8NY.01", "TCGA.G7.6789.01", "TCGA.G7.6790.01", 
"TCGA.G7.6792.01", "TCGA.G7.6793.01", "TCGA.G7.6797.01", "TCGA.G7.7501.01", 
"TCGA.G7.7502.01", "TCGA.G7.A4TM.01", "TCGA.G7.A8LB.01", "TCGA.G7.A8LC.01", 
"TCGA.G7.A8LD.01", "TCGA.G7.A8LE.01", "TCGA.GL.6846.01", "TCGA.GL.7773.01", 
"TCGA.GL.7966.01", "TCGA.GL.8500.01", "TCGA.GL.A59R.01", "TCGA.GL.A9DC.01", 
"TCGA.GL.A9DD.01", "TCGA.GL.A9DE.01", "TCGA.IA.A40U.01", "TCGA.IA.A40X.01", 
"TCGA.IA.A40Y.01", "TCGA.IZ.8196.01", "TCGA.J7.6720.01", "TCGA.J7.8537.01", 
"TCGA.J7.A8I2.01", "TCGA.KV.A6GD.01", "TCGA.KV.A6GE.01", "TCGA.KV.A74V.01", 
"TCGA.MH.A55Z.01", "TCGA.MH.A560.01", "TCGA.MH.A562.01", "TCGA.MH.A855.01", 
"TCGA.P4.A5E6.01", "TCGA.P4.A5E7.01", "TCGA.P4.A5E8.01", "TCGA.P4.A5EA.01", 
"TCGA.P4.A5ED.01", "TCGA.P4.AAVL.01", "TCGA.P4.AAVM.01", "TCGA.PJ.A5Z8.01", 
"TCGA.PJ.A5Z9.01", "TCGA.Q2.A5QZ.01", "TCGA.SX.A71R.01", "TCGA.SX.A71U.01", 
"TCGA.SX.A7SM.01", "TCGA.SX.A7SN.01", "TCGA.SX.A7SO.01", "TCGA.SX.A7SP.01", 
"TCGA.SX.A7SR.01", "TCGA.SX.A7SS.01", "TCGA.UZ.A9PJ.01", "TCGA.UZ.A9PK.01", 
"TCGA.UZ.A9PL.01", "TCGA.UZ.A9PN.01", "TCGA.UZ.A9PP.01", "TCGA.UZ.A9PR.01", 
"TCGA.UZ.A9PS.01", "TCGA.UZ.A9PU.01", "TCGA.UZ.A9PV.01", "TCGA.UZ.A9PX.01", 
"TCGA.UZ.A9PZ.01", "TCGA.UZ.A9Q0.01", "TCGA.V9.A7HT.01", "TCGA.Y8.A894.01", 
"TCGA.Y8.A895.01", "TCGA.Y8.A896.01", "TCGA.Y8.A897.01", "TCGA.Y8.A8RY.01", 
"TCGA.Y8.A8RZ.01", "TCGA.Y8.A8S0.01", "TCGA.Y8.A8S1.01")


所需输出格式示例:

rownames(clin.info)
"TCGA-2K-A9WE-01A-11D-A381-01"
"TCGA-2Z-A9J1-01A-11D-A381-01" "TCGA-2Z-A9J2-01A-11D-A381-01"

0md85ypi

0md85ypi1#

# Replace row names in clin.info
for (i in 1:nrow(clin.info)) {
  match_idx <- grep(substr(rownames(clin.info)[i], 1, 16), maf$Tumor_Sample_Barcode)
  if (length(match_idx) > 0) {
    rownames(clin.info)[i] <- maf$Tumor_Sample_Barcode[match_idx]
  }
}

字符串
这段代码使用一个循环遍历clin.info中的每个行名称。它使用substr提取前16个字符(匹配maf$Tumor_Sample_Barcode中子字符串的长度)。然后,它使用grep在maf$Tumor_Sample_Barcode中查找匹配子字符串的索引。如果找到匹配,则将clin.info中的行名称替换为maf$Tumor_Sample_Barcode中相应的值。

相关问题