Module: RGFATools::CopyNumber
- Included in:
- RGFATools
- Defined in:
- lib/rgfatools/copy_number.rb
Overview
Methods which edit the graph components without traversal
Instance Method Summary collapse
-
#apply_copy_number(segment, count_tag: :cn, distribute: :auto, copy_names_suffix: :lowcase, origin_tag: :or, conserve_components: true) ⇒ RGFA
Applies the computed copy number to a segment.
-
#apply_copy_numbers(count_tag: :cn, distribute: :auto, copy_names_suffix: :lowcase, origin_tag: :or, conserve_components: true) ⇒ RGFA
Applies the computed copy number to all segments.
-
#compute_copy_numbers(single_copy_coverage, mincov: single_copy_coverage * 0.25, count_tag: , cn_tag: :cn, unit_length: ) ⇒ RGFA
Self.
-
#delete_low_coverage_segments(mincov, count_tag: , unit_length: ) ⇒ RGFA
Delete segments which have a coverage under a specified value.
-
#set_count_unit_length(unit_length) ⇒ RGFA
Sets the unit length (k-mer size, average read lenght or average fragment length) to use for coverage computation (defaults to: 1).
-
#set_default_count_tag(tag) ⇒ RGFA
Sets the count tag to use as default by coverage computations (defaults to:
:RC
).
Instance Method Details
#apply_copy_number(segment, count_tag: :cn, distribute: :auto, copy_names_suffix: :lowcase, origin_tag: :or, conserve_components: true) ⇒ RGFA
Applies the computed copy number to a segment
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rgfatools/copy_number.rb', line 97 def apply_copy_number(segment, count_tag: :cn, distribute: :auto, copy_names_suffix: :lowcase, origin_tag: :or, conserve_components: true) s, sn = segment_and_segment_name(segment) factor = s.get!(count_tag) multiply_extended(sn, factor, distribute: distribute, copy_names: copy_names_suffix, conserve_components: conserve_components, origin_tag: origin_tag) self end |
#apply_copy_numbers(count_tag: :cn, distribute: :auto, copy_names_suffix: :lowcase, origin_tag: :or, conserve_components: true) ⇒ RGFA
Applies the computed copy number to all segments
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/rgfatools/copy_number.rb', line 113 def apply_copy_numbers(count_tag: :cn, distribute: :auto, copy_names_suffix: :lowcase, origin_tag: :or, conserve_components: true) segments.sort_by{|s|s.get!(count_tag)}.each do |s| multiply_extended(s.name, s.get(count_tag), distribute: distribute, copy_names: copy_names_suffix, conserve_components: conserve_components, origin_tag: origin_tag) end self end |
#compute_copy_numbers(single_copy_coverage, mincov: single_copy_coverage * 0.25, count_tag: , cn_tag: :cn, unit_length: ) ⇒ RGFA
Returns self.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rgfatools/copy_number.rb', line 62 def compute_copy_numbers(single_copy_coverage, mincov: single_copy_coverage * 0.25, count_tag: @default[:count_tag], cn_tag: :cn, unit_length: @default[:unit_length]) segments.each do |s| cov = s.coverage!(count_tag: count_tag, unit_length: unit_length).to_f if cov < mincov cn = 0 elsif cov < single_copy_coverage cn = 1 else cn = (cov / single_copy_coverage).round end s.set(cn_tag, cn) end self end |
#delete_low_coverage_segments(mincov, count_tag: , unit_length: ) ⇒ RGFA
Delete segments which have a coverage under a specified value.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rgfatools/copy_number.rb', line 40 def delete_low_coverage_segments(mincov, count_tag: @default[:count_tag], unit_length: @default[:unit_length]) segments.map do |s| cov = s.coverage(count_tag: count_tag, unit_length: unit_length) cov < mincov ? s.name : nil end.compact.each do |sn| delete_segment(sn) end self end |
#set_count_unit_length(unit_length) ⇒ RGFA
Sets the unit length (k-mer size, average read lenght or average fragment length) to use for coverage computation (defaults to: 1).
22 23 24 25 |
# File 'lib/rgfatools/copy_number.rb', line 22 def set_count_unit_length(unit_length) @default[:unit_length] = unit_length return self end |
#set_default_count_tag(tag) ⇒ RGFA
Sets the count tag to use as default by coverage computations (defaults to: :RC
).
11 12 13 14 |
# File 'lib/rgfatools/copy_number.rb', line 11 def set_default_count_tag(tag) @default[:count_tag] = tag return self end |