Skip to content

Commit

Permalink
feat(peakPicking): Filters based on the median of the height
Browse files Browse the repository at this point in the history
Filters all objects that are bellow `heightFilter` times the median of the height
  • Loading branch information
maasencioh committed Sep 21, 2016
1 parent 375acde commit 0e3b384
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 11 deletions.
53 changes: 44 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h3 class='fl m0' id='chromatogram'>
Chromatogram
</h3>

<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/d5e09fced09eb674834ea31e83c7212df3310af7/src/Chromatogram.js#L9-L84'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/375acde3f7b6f03d0e03c4f19b057e78003826ab/src/Chromatogram.js#L9-L84'>
<span>src/Chromatogram.js</span>
</a>

Expand Down Expand Up @@ -493,7 +493,7 @@ <h3 class='fl m0' id='peakpicking'>
peakPicking
</h3>

<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/d5e09fced09eb674834ea31e83c7212df3310af7/src/peakPicking.js#L10-L56'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/375acde3f7b6f03d0e03c4f19b057e78003826ab/src/peakPicking.js#L12-L60'>
<span>src/peakPicking.js</span>
</a>

Expand All @@ -503,7 +503,7 @@ <h3 class='fl m0' id='peakpicking'>
<p>Apply the GSD peak picking algorithm</p>


<div class='pre p1 fill-light mt0'>peakPicking(chrom: <a href="#chromatogram">Chromatogram</a>): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>&gt;</div>
<div class='pre p1 fill-light mt0'>peakPicking(chrom: <a href="#chromatogram">Chromatogram</a>, options: [<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>]): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>&gt;</div>



Expand All @@ -525,6 +525,41 @@ <h3 class='fl m0' id='peakpicking'>

</div>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>([<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>])</code> Options object

</div>

<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>

<tr>
<td class='break-word'><span class='code bold'>options.heightFilter</span> <code class='quiet'>[<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>]</code>

(default <code>2</code>)
</td>
<td class='break-word'><span>Filter all objects that are bellow
<code>heightFilter</code>
times the median of the height
</span></td>
</tr>

</tbody>
</table>

</div>

</div>


Expand Down Expand Up @@ -562,7 +597,7 @@ <h3 class='fl m0' id='massinpeaks'>
massInPeaks
</h3>

<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/d5e09fced09eb674834ea31e83c7212df3310af7/src/massInPeaks.js#L15-L58'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/375acde3f7b6f03d0e03c4f19b057e78003826ab/src/massInPeaks.js#L15-L58'>
<span>src/massInPeaks.js</span>
</a>

Expand Down Expand Up @@ -690,7 +725,7 @@ <h3 class='fl m0' id='vectorify'>
vectorify
</h3>

<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/d5e09fced09eb674834ea31e83c7212df3310af7/src/vectorify.js#L16-L55'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/375acde3f7b6f03d0e03c4f19b057e78003826ab/src/vectorify.js#L16-L54'>
<span>src/vectorify.js</span>
</a>

Expand Down Expand Up @@ -828,7 +863,7 @@ <h3 class='fl m0' id='cosine'>
cosine
</h3>

<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/d5e09fced09eb674834ea31e83c7212df3310af7/src/cosine.js#L11-L43'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/375acde3f7b6f03d0e03c4f19b057e78003826ab/src/cosine.js#L11-L43'>
<span>src/cosine.js</span>
</a>

Expand Down Expand Up @@ -921,7 +956,7 @@ <h3 class='fl m0' id='massfilter'>
massFilter
</h3>

<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/d5e09fced09eb674834ea31e83c7212df3310af7/src/massFilter.js#L43-L85'>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/cheminfo-js/chromatography/blob/375acde3f7b6f03d0e03c4f19b057e78003826ab/src/massFilter.js#L43-L83'>
<span>src/massFilter.js</span>
</a>

Expand All @@ -931,7 +966,7 @@ <h3 class='fl m0' id='massfilter'>
<p>Filters a mass object</p>


<div class='pre p1 fill-light mt0'>massFilter(massXYObject: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, options: [<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>](default {thresholdFactor: 0, maxNumberPeaks: Number.MAX_VALUE, groupWidth: 0})): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
<div class='pre p1 fill-light mt0'>massFilter(massXYObject: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, options: [<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>](default {})): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>



Expand Down Expand Up @@ -985,7 +1020,7 @@ <h3 class='fl m0' id='massfilter'>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>([<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>](default {thresholdFactor: 0, maxNumberPeaks: Number.MAX_VALUE, groupWidth: 0}))</code> Options for the integral filtering
<span class='code bold'>options</span> <code class='quiet'>([<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>](default {}))</code> Options for the integral filtering

</div>

Expand Down
8 changes: 6 additions & 2 deletions src/peakPicking.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ const gsd = require('ml-gsd').gsd;
/**
* Apply the GSD peak picking algorithm
* @param {Chromatogram} chrom - GC/MS chromatogram where make the peak picking
* @param {Object} [options] - Options object
* @param {Object} [options.heightFilter = 2] - Filter all objects that are bellow `heightFilter` times the median of the height
* @return {Array<Object>} - List of GSD objects
*/
function peakPicking(chrom) {
function peakPicking(chrom, options = {}) {
const {heightFilter = 2} = options;

let tic = chrom.findSerieByName('tic');
if (!tic) {
throw new Error('\'tic\' serie not founded');
Expand Down Expand Up @@ -50,7 +54,7 @@ function peakPicking(chrom) {

// filter height by factor
let medianHeight = peakList[Math.floor((peakList.length - 1) / 2)].height;
peakList = peakList.filter((val) => val.height > medianHeight * 2);
peakList = peakList.filter((val) => val.height > medianHeight * heightFilter);

return peakList;
}
Expand Down

0 comments on commit 0e3b384

Please sign in to comment.