I am using d3.tsv to parse through a file. I want to change all the zeros in one column of the data(PValue column) to the next lowest number in that column. I believe the correct way of doing this is to use the accessor function but my attempts have so far failed.
d3.tsv(filename, modifyData, function(error, data) {
data.forEach(function(d) {
d.NAME = d.NAME;
d.logFC = +d.logFC;
d.logCPM = +d.logCPM;
d.FDR = +d.FDR;
d.PValue = +d.PValue
});
})
When I try to do something like the following in the accessor function modifyData, I get an error saying 'data' is undefined in the code above.
function modifyData(d){
d.forEach(function(origData){
origData.PValue = +origData.PValue
pValue_array.push(origData.PValue)
})
var pValue_array = []
for (var i = pValue_array.length-1 ; i >= 0; i--){
if (pValue_array[i] === 0){
pValue_array.splice(i,1);
}
}
var newPzero = (arrayMin(pValue_array))
return d;
};
arrayMin is a simple function that returns the minimum value in an array. I was planning on using this value to replace all of the 0s in the PValue column. Help is greatly appreciated!