亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 2427 | 回復(fù): 6
打印 上一主題 下一主題

perl統(tǒng)計(jì)替換 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2013-03-15 11:21 |只看該作者 |倒序?yàn)g覽
test.zip (5.03 KB, 下載次數(shù): 7)

文件1.txt
Entrez_Gene_Id        Tumor_Sample_Barcode
182        TCGA-02-0043-01A-01W
220        TCGA-02-0089-01A-01W
220        TCGA-02-0028-01A-01W
286        TCGA-02-0083-01A-01W
286        TCGA-02-0028-01A-01W
287        TCGA-02-0015-01A-01W-0318-08
287        TCGA-08-0354-01A-01W-0318-08
287        TCGA-02-0064-01A-01W-0206-08
301        TCGA-02-0028-01A-01W
310        TCGA-02-0083-01A-01W-0206-08
324        TCGA-02-0015-01A-01W-0318-08
472        TCGA-02-0010-01A-01W-0189-08
472        TCGA-02-0114-01A-01W-0206-08
473        TCGA-02-0114-01A-01W
477        TCGA-02-0083-01A-01W
529        TCGA-02-0083-01A-01W-0206-08
——————————————————————————————————

文件2.txt

Term         Genes
hsa05200athways in cancer        1436, 6469, 5579, 6772, 1956, 5578, 2033, 862, 3082, 1029, 2335, 867, 7472, 3320, 2956, 7048, 4233, 5159, 5601, 2064, 5728, 675, 2735, 5156, 1441, 3815, 324, 2322, 4193, 5925, 2737, 5727, 7157, 2260, 5290, 4089, 5294, 5295, 999
hsa04510:Focal adhesion        5579, 1956, 5578, 3082, 2335, 1289, 4233, 5159, 5601, 57144, 2064, 1281, 5728, 5156, 3371, 2321, 85366, 9564, 3791, 5170, 3690, 1301, 3611, 1793, 5290, 1277, 2909, 5294, 5295, 7057
hsa05218:Melanoma        5728, 5156, 1956, 3082, 1029, 4193, 5925, 7157, 2260, 5290, 5294, 5295, 4233, 5159, 999
hsa05213:Endometrial cancer        5290, 2064, 5728, 1956, 2309, 5170, 324, 3611, 5294, 5295, 7157, 999
hsa05214:Glioma        5728, 5579, 5156, 1956, 5578, 1029, 4193, 5925, 7157, 5290, 5294, 5295, 5159
hsa05215rostate cancer        5728, 2064, 5156, 1956, 2033, 5170, 4193, 5925, 7157, 2260, 5290, 3320, 5294, 5295, 5159
hsa05223:Non-small cell lung cancer        5290, 2064, 5579, 5578, 1956, 2309, 1029, 5170, 5925, 5294, 5295, 7157
hsa05212ancreatic cancer        5601, 2064, 675, 6772, 1956, 1029, 5925, 7157, 5290, 4089, 7048, 5294, 5295
hsa05210:Colorectal cancer        5601, 5156, 1956, 324, 7157, 5290, 4089, 2956, 7048, 5294, 5295, 4233, 5159
hsa04070hosphatidylinositol signaling system        5290, 5728, 5579, 5578, 3710, 79837, 5287, 8527, 5288, 5294, 5286, 5295
————————————————————————————————————————————————————————————————————

目的:
Term        Genes
hsa05200athways in cancer        TCGA-02-0084-01A-01W TCGA-08-0390-01A-01W TCGA-06-0185-01A-01W-0254-08 TCGA-06-0185-01A-01W TCGA-02-0010-01A-01W-0189-08 TCGA-02-0083-01A-01W-0206-08 TCGA-02-0028-01A-01W TCGA-02-0083-01A-01W-0206-08 TCGA-08-0390-01A-01W TCGA-02-0114-01A-01W TCGA-02-0114-01A-01W-0206-08 TCGA-02-0083-01A-01W-0206-08 TCGA-02-0099-01A-01W TCGA-02-0083-01A-01W TCGA-02-0043-01A-01W TCGA-02-0014-01A-01W-0189-08 TCGA-02-0010-01A-01W TCGA-02-0083-01A-01W TCGA-02-0014-01A-01W-0189-08 TCGA-02-0113-01A-01W TCGA-06-0213-01A-01W-0254-08 TCGA-02-0014-01A-01W-0189-08 TCGA-06-0133-01A-02W-0224-08 TCGA-08-0347-01A-01W-0318-08 TCGA-02-0014-01A-01W-0189-08 TCGA-02-0083-01A-01W-0206-08 TCGA-02-0015-01A-01W-0318-08 TCGA-06-0125-01A-01W TCGA-02-0085-01A-01W-0206-08 TCGA-06-0206-01A-01W-0254-08 TCGA-02-0083-01A-01W TCGA-06-0125-01A-01W TCGA-06-0188-01A-01W TCGA-08-0245-01A-01W-0318-08 TCGA-06-0201-01A-01W TCGA-02-0028-01A-01W-0189-08 TCGA-02-0114-01A-01W TCGA-02-0048-01A-01W TCGA-06-0210-01A-01W
hsa05218:Melanoma        TCGA-06-0213-01A-01W-0254-08 TCGA-08-0347-01A-01W-0318-08 TCGA-02-0010-01A-01W-0189-08 TCGA-08-0390-01A-01W TCGA-02-0114-01A-01W TCGA-02-0085-01A-01W-0206-08 TCGA-06-0206-01A-01W-0254-08 TCGA-06-0188-01A-01W TCGA-08-0245-01A-01W-0318-08 TCGA-06-0201-01A-01W TCGA-02-0114-01A-01W TCGA-02-0048-01A-01W TCGA-02-0010-01A-01W TCGA-02-0083-01A-01W TCGA-06-0210-01A-01W                                  


我寫的代碼如下
  1. #!usr/bin/perl
  2. use strict;
  3. use warnings;


  4. open (IN1, $ARGV[0]) or die $!;
  5. open (IN2, $ARGV[1]) or die $!;
  6. open (OUT, ">$ARGV[2]") or die $!;

  7. my %h;
  8. while(<IN1>){
  9.         chomp;
  10.         my @m=split(/\t/,$_);
  11.         $h{$m[0]}=$m[1];           
  12. }                                                     
  13. while(<IN2>)                                          
  14. {                                                     
  15. chomp;                                                
  16. my @a=split(/\t/,$_);
  17. my @m=split(", ",$a[1]);
  18. for (0..$#m){
  19.         $m[$_]=$h{$m[$_]} if exists($h{$m[$_]});
  20.         }
  21.         print OUT "$a[0]\t@m\n";
  22.         }
復(fù)制代碼
————————————————————————————————

錯(cuò)誤:
1. 文件1.txt中,第一列是有重復(fù)的,結(jié)果中只有對(duì)應(yīng)的一個(gè)。
例如:286        TCGA-02-0083-01A-01W
286        TCGA-02-0028-01A-01W
而結(jié)果只是對(duì)應(yīng)了第一個(gè),第二個(gè)沒(méi)有展示。
2. 結(jié)果中有重復(fù)的
例如:hsa05200athways in cancer中出現(xiàn)了兩次:
TCGA-02-0014-01A-01W-0189-08
TCGA-02-0014-01A-01W-0189-08

請(qǐng)教,

這個(gè)perl應(yīng)該怎么寫?




論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2013-03-15 13:21 |只看該作者
...............................

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2013-03-15 14:12 |只看該作者
本帖最后由 kk861123 于 2013-03-15 18:15 編輯
  1. #!usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Data::Dumper;

  5. open (IN1, $ARGV[0]) or die $!;
  6. open (IN2, $ARGV[1]) or die $!;
  7. open (OUT, ">$ARGV[2]") or die $!;


  8. my %h;
  9. my $title1 = <IN1>;
  10. while(<IN1>){
  11.     chomp;
  12.     my @m=split(/\t/,$_);
  13.     #$h{$m[0]}=$m[1];      
  14.     push @{ $h{$m[0]} }, $m[1];
  15. }            

  16. my $title2 = <IN2>;         
  17. while(<IN2>)                                          
  18. {                                                     
  19.     my ($sTerm, $sGenes) = split(/\t/,$_, 2);
  20.     my @aGenes = split /\s*,\s*/ => $sGenes;
  21.     my ( @barcode, %hUniq );
  22.     for my $g (@aGenes) {
  23.         next unless exists $h{$g};
  24.         map { push @barcode, $_ } grep { !$hUniq{$_}++ } @{ $h{$g} };
  25.     }
  26.     print OUT "$sTerm\t@barcode\n";
  27.     print "$_ => $hUniq{$_}\n" for @barcode;  # new add 2013.18:15
  28. }
復(fù)制代碼
回復(fù) 2# xingzhou823


   

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2013-03-15 14:57 |只看該作者
回復(fù) 3# kk861123

謝謝,我運(yùn)行了一下,直接就出結(jié)果了。并且沒(méi)有重復(fù)的。

請(qǐng)問(wèn),我現(xiàn)在順便想統(tǒng)計(jì)對(duì)應(yīng)樣品的個(gè)數(shù),能不能在剛才的代碼中直接修改,得到?


   

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2013-03-15 18:16 |只看該作者
回復(fù) 4# xingzhou823


    已修正,看3樓代碼

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2013-03-18 09:21 |只看該作者
回復(fù) 4# xingzhou823

不好意思,代碼我看了,是我沒(méi)說(shuō)清楚。不是統(tǒng)計(jì)原始數(shù)據(jù)1中的樣品數(shù)。

我想統(tǒng)計(jì)的是得到的結(jié)果中,例如:某一行:

hsa05214:Glioma        TCGA-02-0052-01A-01W TCGA-02-0027-01A-01W TCGA-02-0001-01C-01W TCGA-06-0644-01A-02W TCGA-08-0348-01A-01W TCGA-06-0125-01A-01W TCGA-06-0206-01A-01W TCGA-06-0188-01A-01W TCGA-06-0168-01A-01W TCGA-08-0345-01A-01W TCGA-12-0618-01A-01W TCGA-12-0620-01A-01W TCGA-06-0184-01A-01W TCGA-06-0208-01A-01W TCGA-06-0190-01A-01W TCGA-02-0014-01A-01W TCGA-02-0055-01A-01W TCGA-06-0187-01A-01W TCGA-06-0195-01B-01W TCGA-02-0079-01A-01W TCGA-02-0021-01A-01W TCGA-06-0166-01A-01W TCGA-02-0038-01A-01W TCGA-02-0007-01A-01W TCGA-02-0113-01A-01W TCGA-02-0075-01A-01W TCGA-08-0389-01A-01W TCGA-06-0124-01A-01W TCGA-06-0184-01A-01W-0254-08 TCGA-08-0359-01A-01W-0318-08 TCGA-06-0208-01A-01W-0254-08 TCGA-06-0190-01A-01W-0254-08 TCGA-02-0014-01A-01W-0189-08 TCGA-02-0055-01A-01W-0189-08 TCGA-06-0187-01A-01W-0254-08 TCGA-06-0195-01B-01W-0254-08 TCGA-02-0079-01A-01W-0323-08 TCGA-06-0166-01A-01W-0254-08 TCGA-02-0038-01A-01W-0189-08 TCGA-02-0007-01A-01W-0189-08 TCGA-02-0075-01A-01W-0206-08 TCGA-06-0138-01A-01W TCGA-06-0176-01A-02W TCGA-08-0380-01A-01W TCGA-06-0138-01A-01W-0254-08 TCGA-06-0176-01A-02W-0254-08 TCGA-08-0380-01A-01W-0318-08 TCGA-02-0015-01A-01W-0318-08 TCGA-02-0099-01A-01W-0206-08 TCGA-02-0004-01A-01W-0318-08 TCGA-08-0352-01A-01W-0323-08 TCGA-06-0213-01A-01W-0254-08 TCGA-06-0185-01A-01W-0254-08 TCGA-06-0174-01A-01W TCGA-08-0347-01A-01W TCGA-08-0245-01A-01W-0318-08 TCGA-08-0347-01A-01W-0318-08 TCGA-02-0003-01A-01W TCGA-08-0390-01A-01W TCGA-06-0154-01A-02W TCGA-08-0246-01A-01W TCGA-02-0089-01A-01W TCGA-02-0016-01A-01W TCGA-02-0023-01B-01W TCGA-02-0054-01A-01W TCGA-08-0355-01A-01W TCGA-06-0127-01A-01W TCGA-02-0046-01A-01W TCGA-06-0185-01A-01W TCGA-02-0010-01A-01W TCGA-06-0237-01A-02W-0254-08 TCGA-08-0390-01A-01W-0318-08 TCGA-02-0021-01A-01W-0189-08 TCGA-08-0246-01A-01W-0318-08 TCGA-02-0089-01A-01W-0206-08 TCGA-06-0148-01A-01W-0224-08 TCGA-06-0148-01A-03W-0254-08 TCGA-06-0157-01A-01W-0254-08 TCGA-06-0127-01A-01W-0323-08 TCGA-08-0349-01A-01W-0323-08 TCGA-02-0116-01A-01W-0206-08 TCGA-02-0046-01A-01W-0189-08 TCGA-06-0125-01A-01W-0224-08 TCGA-12-0616-01A-01W-0323-08 TCGA-02-0003-01A-01W-0189-08 TCGA-02-0010-01A-01W-0189-08 TCGA-02-0083-01A-01W-0206-08 TCGA-02-0083-01A-01W TCGA-02-0114-01A-01W TCGA-02-0085-01A-01W-0206-08 TCGA-06-0213-01A-01W TCGA-12-0619-01A-01W TCGA-02-0033-01A-01W TCGA-02-0052-01A-01W-0189-08 TCGA-06-0206-01A-01W-0254-08 TCGA-06-0221-01A-01W TCGA-02-0080-01A-01W TCGA-02-0058-01A-01W TCGA-02-0034-01A-01W TCGA-06-0241-01A-02W TCGA-02-0074-01A-01W TCGA-08-0351-01A-01W TCGA-08-0359-01A-01W TCGA-06-0237-01A-02W TCGA-08-0245-01A-01W TCGA-02-0037-01A-01W TCGA-02-0011-01B-01W TCGA-02-0048-01A-01W TCGA-06-0130-01A-01W TCGA-02-0084-01A-01W TCGA-08-0360-01A-01W TCGA-02-0025-01A-01W TCGA-08-0353-01A-01W TCGA-08-0373-01A-01W-0323-08 TCGA-02-0114-01A-01W-0206-08 TCGA-02-0080-01A-01W-0206-08 TCGA-02-0084-01A-01W-0323-08 TCGA-02-0058-01A-01W-0189-08 TCGA-06-0197-01A-02W-0254-08 TCGA-06-0150-01A-01W-0254-08 TCGA-02-0048-01A-01W-0318-08 TCGA-02-0026-01B-01W-0318-08 TCGA-02-0074-01A-01W-0206-08 TCGA-06-0644-01A-02W-0323-08 TCGA-08-0351-01A-01W-0318-08 TCGA-06-0159-01A-01W-0254-08 TCGA-02-0037-01A-01W-0189-08 TCGA-02-0011-01B-01W-0189-08 TCGA-12-0619-01A-01W-0323-08 TCGA-08-0360-01A-01W-0318-08 TCGA-02-0024-01B-01W TCGA-02-0024-01B-01W-0189-08 TCGA-02-0054-01A-01W-0189-08 TCGA-02-0116-01A-01W TCGA-02-0047-01A-01W TCGA-08-0375-01A-01W TCGA-06-0210-01A-01W TCGA-06-0171-01A-02W TCGA-06-0201-01A-01W TCGA-06-0129-01A-01W TCGA-02-0028-01A-01W TCGA-06-0178-01A-01W TCGA-08-0350-01A-01W TCGA-06-0133-01A-02W
——————————————————————————————————————————————————
這一行hsa05214:Glioma中包含的 樣品數(shù)為144個(gè)。



   

論壇徽章:
7
戌狗
日期:2013-12-15 20:43:38技術(shù)圖書(shū)徽章
日期:2014-03-05 01:33:12技術(shù)圖書(shū)徽章
日期:2014-03-15 20:31:17未羊
日期:2014-03-25 23:48:20丑牛
日期:2014-04-07 22:37:44巳蛇
日期:2014-04-11 21:58:0915-16賽季CBA聯(lián)賽之青島
日期:2016-03-17 20:36:13
7 [報(bào)告]
發(fā)表于 2013-03-19 07:04 |只看該作者
看了問(wèn)題。
沒(méi)有知道問(wèn)題。{:3_188:}{:3_188:}
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP