.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Genome::Model::Tools::Music::MutationRelation 3pm" .TH Genome::Model::Tools::Music::MutationRelation 3pm "2020-11-06" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .IP "\-\-bam\-list" 4 .IX Item "--bam-list" .RS 4 .PD 0 .IP "Provide a file containing sample names and normal/tumor \s-1BAM\s0 locations for each. Use the tab\- delimited format [sample_name normal_bam tumor_bam] per line. This tool only needs sample_name, so all other columns can be skipped. The sample_name must be the same as the tumor sample names used in the \s-1MAF\s0 file (16th column, with the header Tumor_Sample_Barcode)." 8 .IX Item "Provide a file containing sample names and normal/tumor BAM locations for each. Use the tab- delimited format [sample_name normal_bam tumor_bam] per line. This tool only needs sample_name, so all other columns can be skipped. The sample_name must be the same as the tumor sample names used in the MAF file (16th column, with the header Tumor_Sample_Barcode)." .RE .RS 4 .RE .PD .PP \&\s-1EOS\s0 ); } .PP sub _doc_authors { return <<\s-1EOS\s0 Nathan D. Dees, Ph.D. Qunyuan Zhang, Ph.D. \&\s-1EOS\s0 } .PP sub execute { # Parse input arguments my \f(CW$self\fR = shift; my \f(CW$bam_list\fR = \f(CW$self\fR\->bam_list; my \f(CW$maf_file\fR = \f(CW$self\fR\->maf_file; my \f(CW$output_file\fR = \f(CW$self\fR\->output_file; my \f(CW$gene_list\fR = \f(CW$self\fR\->gene_list; my \f(CW$permutations\fR = \f(CW$self\fR\->permutations; my \f(CW@all_sample_names\fR; # names of all the samples, no matter if it's mutated or not my \f(CW@genes_to_test\fR; # the genes which will be tested for relationships my \f(CW$skip_non_coding\fR = \f(CW$self\fR\->skip_non_coding; my \f(CW$skip_silent\fR = \f(CW$self\fR\->skip_silent; .PP .Vb 10 \& # Parse out the names of the samples which should match the names in the MAF file \& my $sampleFh = IO::File\->new( $bam_list ) or die "Couldn\*(Aqt open $bam_list. $!\en"; \& my $line_count = 0; \& while( my $line = $sampleFh\->getline ) \& { \& $line_count++; \& next if ( $line =~ m/^#/ ); \& chomp( $line ); \& my ( $sample ) = split( /\et/, $line ); \& if ($sample) { \& push( @all_sample_names, $sample ); \& } else { \& warn("could not parse sample name from line $line_count of \-\-bam_list"); \& } \& } \& $sampleFh\->close; \& \& # If user\-specified, parse out the names of the genes that we are limiting our tests to \& if( defined $gene_list ) \& { \& my $geneFh = IO::File\->new( $gene_list ) or die "Couldn\*(Aqt open $gene_list. $!\en"; \& while( my $line = $geneFh\->getline ) \& { \& next if ( $line =~ m/^#/ ); \& chomp( $line ); \& my ( $gene ) = split( /\et/, $line ); \& push( @genes_to_test, $gene ); \& } \& $geneFh\->close; \& } \& \& # Create sample\-gene matrix \& my $matrix_file = $self\->create_sample_gene_matrix($maf_file, \e@all_sample_names, \e@genes_to_test, $skip_non_coding, $skip_silent); \& \& # Perform mutation\-relation test using R \& my $R_cmd = "R \-\-slave \-\-args < " . _\|_FILE_\|_ . ".R $matrix_file $permutations $output_file"; \& print "$R_cmd\en"; \& WIFEXITED(system $R_cmd) or croak "Couldn\*(Aqt run: $R_cmd ($?)"; \& \& return(1); \&} .Ve .PP sub create_sample_gene_matrix { my \f(CW$self\fR = shift; my ( \f(CW$maf_file\fR, \f(CW$all_sample_names_ref\fR, \f(CW$genes_to_test_ref\fR, \f(CW$skip_non_coding\fR, \f(CW$skip_silent\fR ) = \f(CW@_\fR; my \f(CW@all_sample_names\fR = @{$all_sample_names_ref}; my \f(CW@genes_to_test\fR = @{$genes_to_test_ref}; .PP .Vb 3 \& # Create hash of mutations from the MAF file \& my %mutations; \& my %all_genes; \& \& # Parse the MAF file \& my $mafFh = IO::File\->new( $maf_file ) or die "Couldn\*(Aqt open $maf_file. $!\en"; \& while( my $line = $mafFh\->getline ) \& { \& next if( $line =~ m/^(#|Hugo_Symbol)/ ); \& chomp $line; \& my @cols = split( /\et/, $line ); \& my ( $gene, $mutation_class, $sample ) = ( $cols[0], $cols[8], $cols[15] ); \& \& # If the mutation classification is odd, quit with error \& if( $mutation_class !~ m/^(Missense_Mutation|Nonsense_Mutation|Nonstop_Mutation|Splice_Site|Translation_Start_Site|Frame_Shift_Del|Frame_Shift_Ins|In_Frame_Del|In_Frame_Ins|Silent|Intron|RNA|3\*(AqFlank|3\*(AqUTR|5\*(AqFlank|5\*(AqUTR|IGR|Targeted_Region|De_novo_Start_InFrame|De_novo_Start_OutOfFrame)$/ ) \& { \& print STDERR "Unrecognized Variant_Classification \e"$mutation_class\e" in MAF file for gene $gene\en"; \& print STDERR "Please use TCGA MAF Specification v2.3.\en"; \& return undef; \& } \& \& # If user wants, skip Silent mutations, or those in Introns, RNA, UTRs, Flanks, IGRs, or the ubiquitous Targeted_Region \& if(( $skip_non_coding && $mutation_class =~ m/^(Intron|RNA|3\*(AqFlank|3\*(AqUTR|5\*(AqFlank|5\*(AqUTR|IGR|Targeted_Region)$/ ) || \& ( $skip_silent && $mutation_class =~ m/^Silent$/ )) \& { \& print "Skipping $mutation_class mutation in gene $gene.\en"; \& next; \& } \& \& $all_genes{$gene}++; \& $mutations{$sample}{$gene}++; \& } \& $mafFh\->close; \& \& # If the user specified a gene list, then check for genes that are not in the MAF \& if( scalar( @genes_to_test ) > 0 ) \& { \& for( my $i = 0; $i < scalar( @genes_to_test ); ++$i ) \& { \& unless( defined $all_genes{$genes_to_test[$i]} ) \& { \& print "Skipping ", $genes_to_test[$i], " from specified gene\-list since it was not found in the MAF file\en"; \& splice( @genes_to_test, $i, 1 ); \& } \& } \& } \& else \& { \& @genes_to_test = sort keys %all_genes; \& } \& \& # Write the input matrix to a file for use by the R code \& my $matrix_file; \& unless( $matrix_file = $self\->mutation_matrix_file ) { \& $matrix_file = Genome::Sys\->create_temp_file_path(); \& } \& \& my $matrix_fh = new IO::File $matrix_file,"w"; \& # Print input matrix file header \& my $header = join("\et","Sample",@genes_to_test); \& $matrix_fh\->print("$header\en"); \& \& # Print mutation relation input matrix \& for my $sample (sort @all_sample_names) { \& $matrix_fh\->print($sample); \& for my $gene (@genes_to_test) { \& if (exists $mutations{$sample}{$gene}) { \& $matrix_fh\->print("\et1"); \& } \& else { \& $matrix_fh\->print("\et0"); \& } \& } \& $matrix_fh\->print("\en"); \& } \& \& return $matrix_file; \&} .Ve .PP 1;