pets 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +41 -0
  8. data/Rakefile +6 -0
  9. data/bin/area_under_curve_pr.rb +118 -0
  10. data/bin/association_metrics_average.rb +94 -0
  11. data/bin/coPatReporter.rb +531 -0
  12. data/bin/console +14 -0
  13. data/bin/fmeasure_index.rb +72 -0
  14. data/bin/get_PR_values.rb +90 -0
  15. data/bin/get_clusters.R +18 -0
  16. data/bin/get_network_nodes.rb +197 -0
  17. data/bin/lines.R +77 -0
  18. data/bin/merge_by_cluster.rb +62 -0
  19. data/bin/merge_pairs.rb +138 -0
  20. data/bin/paco_translator.rb +102 -0
  21. data/bin/phen2reg.rb +385 -0
  22. data/bin/phen2reg_predictor_check.rb +297 -0
  23. data/bin/plot_area.R +71 -0
  24. data/bin/plot_boxplot.R +21 -0
  25. data/bin/plot_density.R +46 -0
  26. data/bin/plot_scatterplot.R +25 -0
  27. data/bin/reg2phen.rb +116 -0
  28. data/bin/region_to_patients_generator.rb +84 -0
  29. data/bin/relate_CI_to_association_value.rb +90 -0
  30. data/bin/setup +8 -0
  31. data/bin/standardize_scores.R +40 -0
  32. data/bin/xyplot_graph.R +60 -0
  33. data/external_data/biosystems_gene.gz +0 -0
  34. data/external_data/bsid2info.gz +0 -0
  35. data/external_data/chromosome_sizes_hg19.txt +24 -0
  36. data/external_data/gene_data.gz +0 -0
  37. data/external_data/gene_data_with_pathways.gz +0 -0
  38. data/external_data/gene_location.gz +0 -0
  39. data/external_data/hp.obo +146363 -0
  40. data/external_data/remove +0 -0
  41. data/lib/pets.rb +6 -0
  42. data/lib/pets/coPatReporterMethods.rb +77 -0
  43. data/lib/pets/generalMethods.rb +556 -0
  44. data/lib/pets/phen2reg_methods.rb +432 -0
  45. data/lib/pets/version.rb +3 -0
  46. data/pets.gemspec +47 -0
  47. data/templates/cohort_report.erb +93 -0
  48. data/templates/patient_report.erb +209 -0
  49. metadata +183 -0
@@ -0,0 +1,93 @@
1
+ <%
2
+ def add_tip(text, help_text)
3
+ return "<div class=\"tooltip\">#{text}<span class=\"tooltiptext\">#{help_text}</span></div>"
4
+ end
5
+ %>
6
+
7
+ <div style="width: 90%; background-color:#ecf0f1; margin: 0 auto;">
8
+ <h1 style="text-align: center; background-color:#d6eaf8">Summary stats</h1>
9
+ <p> General stats about the patient cohort</p>
10
+ <%= table(id: :summary_stats, header: true, border: 2,
11
+ cell_align: %w(left center )) do |data|
12
+ data.unshift(['Stat', 'Value'])
13
+ end
14
+ %>
15
+ </div>
16
+
17
+ <div style="width: 90%; background-color:#ecf0f1; margin: 0 auto;">
18
+ <h1 style="text-align: center; background-color:#d6eaf8">HPO stats</h1>
19
+ <p> HPOs more frequent in the cohort </p>
20
+ <%= table(id: :hpo_stats, header: true, border: 2,
21
+ cell_align: %w(left center )) do |data|
22
+ data.unshift(['HPO', ' Patient percentage'])
23
+ end
24
+ %>
25
+ </div>
26
+
27
+ <div style="width: 90%; background-color:#ecf0f1; margin: 0 auto;">
28
+ <h1 style="text-align: center; background-color:#d6eaf8">Cohort genome coverage analysis</h1>
29
+ <p> Distribution of the genome coverage of all mutations characterized in the cohort. Second figure shows the same results for SORs.</p>
30
+ <%=
31
+ plot = File.join(@hash_vars[:temp_folder],'coverage_plot.pdf')
32
+ if File.exists?(plot)
33
+ embed_pdf(File.join(@hash_vars[:temp_folder],'coverage_plot.pdf'), 'width="800" height="800"')
34
+ else
35
+ "<p> No genomic data was specified for this cohort </p>"
36
+ end
37
+ %>
38
+ <%=
39
+ plot = File.join(@hash_vars[:temp_folder],'sor_coverage_plot.pdf')
40
+ if File.exists?(plot)
41
+ embed_pdf(File.join(@hash_vars[:temp_folder],'sor_coverage_plot.pdf'), 'width="800" height="800"')
42
+ else
43
+ "<p> No genomic data was specified for this cohort </p>"
44
+ end
45
+ %>
46
+ <div style="overflow: hidden">
47
+ <h1 style="text-align: center; background-color:#d6eaf8">Distribution of mutations</h1>
48
+ <p> Distribution of all mutations along the genome (Length) and the number of patients that have at least one of them (Count). Second figure shows the same for SORs. </p>
49
+ <%=
50
+ if !@hash_vars[:all_cnvs_length].nil?
51
+ sccater2D(id: :all_cnvs_length, header: false, title: 'CNV', row_names: false, x_label: 'Length', y_label: 'Count', width: "800px", height: "800px", responsive: false)
52
+ else
53
+ "<p> No genomic data was specified for this cohort </p>"
54
+ end
55
+ %>
56
+ <%=
57
+ if !@hash_vars[:all_sor_length].nil?
58
+ sccater2D(id: :all_sor_length, header: false, title: 'SOR', row_names: false, x_label: 'Length', y_label: 'Count', width: "800px", height: "800px", responsive: false)
59
+ else
60
+ "<p> No genomic data was specified for this cohort </p>"
61
+ end
62
+ %>
63
+ </div>
64
+ </div>
65
+
66
+
67
+ <div style="width: 90%; background-color:#ecf0f1; margin: 0 auto;">
68
+ <h1 style="text-align: center; background-color:#d6eaf8">Clustering patients by HPO profile</h1>
69
+ <p> All patients are clustered using their HPO profiles. First figure shows the information coefficient distribution for the top clusters. Second figure shows which chromosomes are affected in the patients for each top cluster. </p>
70
+ <%=
71
+ plot = File.join(@hash_vars[:temp_folder],'scatterplot.pdf')
72
+ if File.exists?(plot)
73
+ embed_pdf(plot, 'width="800" height="800"')
74
+ else
75
+ "<p> Genomic data was not specified </p>"
76
+ end
77
+ %>
78
+ <%= embed_pdf(File.join(@hash_vars[:temp_folder],'boxplot.pdf'), 'width="800" height="800"') %>
79
+
80
+ </div>
81
+
82
+ <div style="width: 90%; background-color:#ecf0f1; margin: 0 auto;">
83
+ <h1 style="text-align: center; background-color:#d6eaf8">HPO frequency by cluster</h1>
84
+ <% @hash_vars[:new_cluster_phenotypes].times do |n| %>
85
+ <%= table(id: "clust_#{n}", header: true, border: 2, row_names: false, text: true,
86
+ cell_align: %w( center )) do |data|
87
+ # data.unshift([add_tip("HPO information in cluster #{n}"), "Patients" "Phenotypes", "Frequency")])
88
+ # data.unshift(["HPO information in cluster #{n}\tPhenotypes\tFrequency"])
89
+ data.unshift(["Patients in Cluster #{n}","Phenotypes", "Frequency"])
90
+ end
91
+ %>
92
+ <%end%>
93
+ </div>
@@ -0,0 +1,209 @@
1
+ <%
2
+ def get_hpo_link(hpo_code)
3
+ # STDERR.puts hpo_code.inspect
4
+ if hpo_code == '-'
5
+ link = '-'
6
+ else
7
+ link = "<a href=\"http://compbio.charite.de/hpoweb/showterm?id=#{hpo_code}\">#{hpo_code}</a>"
8
+ end
9
+ return link
10
+ end
11
+
12
+ def red_text(text)
13
+ return "<font color=\"red\">#{text}</font>"
14
+ end
15
+
16
+ def add_tip(text, help_text)
17
+ return "<div class=\"tooltip\">#{text}<span class=\"tooltiptext\">#{help_text}</span></div>"
18
+ end
19
+
20
+ %>
21
+
22
+ <div class="chunk">
23
+ <style type="text/css" scoped>
24
+ .tooltip {
25
+ position: relative;
26
+ display: inline-block;
27
+ border-bottom: 1px dotted black;
28
+ }
29
+
30
+ .tooltip .tooltiptext {
31
+ visibility: hidden;
32
+ width: 120px;
33
+ background-color: #555;
34
+ color: #fff;
35
+ text-align: center;
36
+ border-radius: 6px;
37
+ padding: 5px 0;
38
+ position: absolute;
39
+ z-index: 1;
40
+ bottom: 125%;
41
+ left: 50%;
42
+ margin-left: -60px;
43
+ opacity: 0;
44
+ transition: opacity 1s;
45
+ }
46
+
47
+ .tooltip .tooltiptext::after {
48
+ content: "";
49
+ position: absolute;
50
+ top: 100%;
51
+ left: 50%;
52
+ margin-left: -5px;
53
+ border-width: 5px;
54
+ border-style: solid;
55
+ border-color: #555 transparent transparent transparent;
56
+ }
57
+
58
+ .tooltip:hover .tooltiptext {
59
+ visibility: visible;
60
+ opacity: 1;
61
+ }
62
+ </style>
63
+ </div>
64
+
65
+ <div style="width: 90%; background-color:#ecf0f1; margin: 0 auto;">
66
+ <h1 style="text-align: center; background-color:#d6eaf8">Input HPO quality control</h1>
67
+ <p>HPO terms with IC values less than <b>1</b> are marked in red, and they do not give much information to our system. Please, if possible, select more specific HPO terms suggested in <b>Possible child HPO terms </b>column.</p>
68
+
69
+ <%= table(id: :characterised_hpos, header: true, border: 2,
70
+ cell_align: %w(left center center center center left)) do |data|
71
+ data.each do |row|
72
+ row.each_with_index do |cell, i|
73
+ if i == 1
74
+ # STDERR.puts cell.inspect
75
+ row[i] = get_hpo_link(cell)
76
+ elsif i == 4
77
+ row[i] = cell.map{|h,n| [get_hpo_link(h), n].compact}.join(', ')
78
+ elsif i == 5
79
+ row[i] = cell.map{|r| "#{get_hpo_link(r.first)} (#{r.last})"}.join(', ')
80
+ elsif i == 3
81
+ ci = cell.to_f
82
+ if ci <= 1
83
+ text = red_text(ci.round(2))
84
+ else
85
+ text = ci.round(2)
86
+ end
87
+ row[i] = text
88
+ elsif i == 2
89
+ if cell == 'no'
90
+ row[i] = red_text(cell)
91
+ end
92
+ end
93
+ end
94
+ end
95
+ data.unshift([add_tip("HPO name", "Name of the HPO"), "HPO code", "Exists in database?", "Information Coefficient (IC)", "Is child of", "Possible child HPO terms"])
96
+ end
97
+ %>
98
+
99
+ <h1 style="text-align: center; background-color:#d6eaf8">Regions associated to HPO profile</h1>
100
+ <h2 style="text-align: center; background-color:#d6eaf8">General representation</h2>
101
+ <div style="overflow: hidden;">
102
+ <%=
103
+ if !@hash_vars[:merged_regions].nil?
104
+ circular_data = []
105
+ @hash_vars[:merged_regions].sort{|reg1, reg2| [reg1[0].to_i, reg1[1].to_i] <=> [reg2[0].to_i, reg2[1].to_i]}.each do |row|
106
+ #TODO if chr were x or y, change them to 23 and 24 and, when print, use x and y again
107
+ circular_data_row = []
108
+ circular_data_row << "#{row[1]}-#{row[2]}"
109
+ circular_data_row << row[5]
110
+ circular_data_row << row[0]
111
+ circular_data << circular_data_row
112
+ end
113
+ circular_data.unshift(%w[Coords CombScore Chr])
114
+ @hash_vars[:circular_data] = circular_data
115
+ circular(
116
+ id: :circular_data,
117
+ header: true,
118
+ row_names: true,
119
+ responsive: false,
120
+ sample_attributes: {'Chr' => 2},
121
+ config:{
122
+ # 'smpLabelOrientation' => 'circular',
123
+ 'smpOverlays' => ['Chr'],
124
+ 'colorSpectrum' => ["#d73027", "#fc8d59", "#fee090", "#ffffbf", "#e0f3f8", "#91bfdb", "#4575b4"],
125
+ # 'segregateSamplesBy' => ['Chr']
126
+ }
127
+ ) do |data|
128
+ data.pop #Discard chromosome data
129
+ end
130
+ end
131
+ %>
132
+ </div>
133
+ <h2 style="text-align: center; background-color:#d6eaf8">Ranked genomic regions associated to the HPO profile</h2>
134
+ <p>The following table shows all the predicted genomic regions, the HPO terms found for it, their original association values and the calculated combined score. Results are ranked from the highest to the lowest combined score.</p>
135
+ <%=
136
+ if !@hash_vars[:merged_regions].nil?
137
+ gene_var = @hash_vars[:genes_with_kegg_data]
138
+ table(id: :merged_regions, header: true, border: 2,
139
+ cell_align: %w(center center center left center center)) do |data|
140
+ hpo_metadata = @hash_vars[:hpo_metadata]
141
+ data.each_with_index do |row, row_number|
142
+ row.each_with_index do |cell, i|
143
+ if i == 3
144
+ row[i] = cell.map{|h| "#{get_hpo_link(h)}: #{hpo_metadata[h][1]}"}.join("\n<br>")
145
+ elsif i == 4
146
+ row[i] = cell.map{|a|
147
+ if a.abs > 0.01
148
+ a.to_f.round(2)
149
+ else
150
+ "%e" %a
151
+ end
152
+ }.join("\n<br>")
153
+ end
154
+ end
155
+ if !gene_var.nil?
156
+ gene_data = gene_var[row_number]
157
+ if !gene_data.empty?
158
+ table = '<table border= "2">'
159
+ table << "<tr><th>#{["GeneID", "Gene Names", "Description", "KEGG pathways"].join('</th><th>')}</th></tr>"
160
+ geneIDs = gene_data.map{|gd| gd.first}
161
+ gene_data.each do |geneID, attributes|
162
+ table << '<tr>'
163
+ table << "<td><a href=https://www.ncbi.nlm.nih.gov/gene/?term=#{geneID}>#{geneID}</a></td>"
164
+ if !attributes.nil?
165
+ table << "<td>#{attributes[0][0..1].join(', ')}</td>"
166
+ table << "<td>#{attributes[1]}</td>"
167
+ table << "<td>#{attributes[2].map{|pws| "<a href=\"https://www.kegg.jp/pathway/#{pws.first}+#{geneIDs.join('+')}\">#{pws.last}</a>"}.join('<br>')}</td>"
168
+ else
169
+ table << '<td></td>' * 3
170
+ end
171
+ table << '</tr>'
172
+ end
173
+ table << '</table>'
174
+ row << table
175
+ else
176
+ row << ('-')
177
+ end
178
+ else
179
+ row << ('-')
180
+ end
181
+ end
182
+ data.unshift(["Chromosome", "Start", "Stop", "Associated HPOs", "Association values<br>(For each HPO)", "Combined score", "Gene data" ])
183
+ end
184
+ end
185
+ %>
186
+
187
+ <% if !@hash_vars[:pathway_stats].empty? %>
188
+ <h2 style="text-align: center; background-color:#d6eaf8">KEGG pathways significance in the genes located into the predicted regions </h2>
189
+ <p></p>
190
+ <%= table(id: :pathway_stats, header: true, border: 2 ) do |data|
191
+ data.each do |row|
192
+ row.each_with_index do |field, i|
193
+ new_field = field
194
+ if i == 0
195
+ new_field = "<a href=\"https://www.kegg.jp/pathway/#{field.first}+#{row[i+1].join('+')}\">#{field.last}</a>"
196
+ elsif i == 1
197
+ new_field = field.map{|geneID| "<a href=https://www.ncbi.nlm.nih.gov/gene/?term=#{geneID}>#{geneID}</a>" }.join(', ')
198
+ elsif i == 2
199
+ new_field = field.join(", ")
200
+ end
201
+ row[i] = new_field
202
+ end
203
+ end
204
+ data.unshift(["KEGG pathway", "Genes in pathway", "Contigency table: PN, NP, PP, NN", "Fisher p-value" ])
205
+ end
206
+ %>
207
+ <% end %>
208
+
209
+ </div>
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Elena Rojano, Pedro Seoane
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: statistics2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: terminal-table
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: report_html
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: PETS suite includes three different tools. CohortAnalyzer performs the
98
+ calculation of several statistics that gives an overview of a cohort of patients
99
+ to analyse. Reg2Phen uses associations between pathological phenotypes and regions
100
+ of the genome (these associations can be calculated from the cohort of patients
101
+ if they include genotypic & phenotypic information using NetAnalyzer, another Ruby
102
+ gem) to find, for a given genomic region, which pathological phenotypes have been
103
+ associated with that region. The third tool, Phen2Reg, is a predictor that using
104
+ the same associations as Reg2Phen, predicts which genomic regions can be the cause
105
+ of a list of pathological phenotypes observed in a patient.
106
+ email:
107
+ - elenarojano@uma.es, seoanezonjic@uma.es
108
+ executables: []
109
+ extensions: []
110
+ extra_rdoc_files: []
111
+ files:
112
+ - ".gitignore"
113
+ - ".rspec"
114
+ - ".travis.yml"
115
+ - Gemfile
116
+ - LICENSE.txt
117
+ - README.md
118
+ - Rakefile
119
+ - bin/area_under_curve_pr.rb
120
+ - bin/association_metrics_average.rb
121
+ - bin/coPatReporter.rb
122
+ - bin/console
123
+ - bin/fmeasure_index.rb
124
+ - bin/get_PR_values.rb
125
+ - bin/get_clusters.R
126
+ - bin/get_network_nodes.rb
127
+ - bin/lines.R
128
+ - bin/merge_by_cluster.rb
129
+ - bin/merge_pairs.rb
130
+ - bin/paco_translator.rb
131
+ - bin/phen2reg.rb
132
+ - bin/phen2reg_predictor_check.rb
133
+ - bin/plot_area.R
134
+ - bin/plot_boxplot.R
135
+ - bin/plot_density.R
136
+ - bin/plot_scatterplot.R
137
+ - bin/reg2phen.rb
138
+ - bin/region_to_patients_generator.rb
139
+ - bin/relate_CI_to_association_value.rb
140
+ - bin/setup
141
+ - bin/standardize_scores.R
142
+ - bin/xyplot_graph.R
143
+ - external_data/biosystems_gene.gz
144
+ - external_data/bsid2info.gz
145
+ - external_data/chromosome_sizes_hg19.txt
146
+ - external_data/gene_data.gz
147
+ - external_data/gene_data_with_pathways.gz
148
+ - external_data/gene_location.gz
149
+ - external_data/hp.obo
150
+ - external_data/remove
151
+ - lib/pets.rb
152
+ - lib/pets/coPatReporterMethods.rb
153
+ - lib/pets/generalMethods.rb
154
+ - lib/pets/phen2reg_methods.rb
155
+ - lib/pets/version.rb
156
+ - pets.gemspec
157
+ - templates/cohort_report.erb
158
+ - templates/patient_report.erb
159
+ homepage: https://bitbucket.org/elenarojano/reg2phen/src/master/bin/reg2phen.rb
160
+ licenses:
161
+ - MIT
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.6.14
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: Suite with predictive tools.
183
+ test_files: []