Hi I have a boxplot as below: Here boxes of similar color determines similar class
I want to achieve right side names to be categorized variable as shown as below example: desired image
So far I was able to differentiate the colors but not able to categorize my code is: $.ajax(
{
async: false,
url: tableData,
method: 'GET',
success: function (data)
{
console.log(data);
var dataout=CSVToArray(data);
const cols = [33,34,35,36,37,38,39,40,41,42,43,44,45,46];
const res = dataout.map(r => cols.map(i => r[i-1]));
var sHAP_tiles=res[0];
var shapgeneArr=res.slice(1, res.length);
var shapDict={};
//INITIALIZING SHAP DICT
for(var j=0;j<sHAP_tiles.length;j++){
if( j==sHAP_tiles.length){
continue;
}
else{
shapDict[sHAP_tiles[j]]=[];
}
}
//FILLING SHAP DICT
for(var i=0;i<shapgeneArr.length;i++){
var currentLst=shapgeneArr[i];
for(var j=0;j<sHAP_tiles.length;j++){
if(j==sHAP_tiles.length){
continue;
}
else{
shapDict[sHAP_tiles[j]].push(parseFloat(currentLst[j]));
}
}
}
var keysForIt=Object.keys(shapDict).reverse();
console.log('keysForIt VALUES',keysForIt);
var traces=[];
// var yvar = ['immune scores', 'chop binding', 'peptide features']
for(var i=0;i<keysForIt.length;i++){
if(keysForIt[i]=='SHAP_pep_NRP' || keysForIt[i]=='SHAP_pep_Rscore'|| keysForIt[i]=='SHAP_pep_DAI' || keysForIt[i]=='SHAP_iedb_immunescore')
{clr='#FF851B'
namefeat='immne scores' }
else if(keysForIt[i]=='SHAP_neo_aff' || keysForIt[i]=='SHAP_neo_rank'|| keysForIt[i]=='SHAP_pep_Cle' || keysForIt[i]=='SHAP_pep_Comb'|| keysForIt[i]=='SHAP_pep_TAP')
{clr='#FF4136'
namefeat='chop binding'}
else{clr='#3D9970'
namefeat='peptide features'}
var temptrace={
x: shapDict[keysForIt[i]],
type: 'box',
boxmean: false,
y:namefeat,
name: keysForIt[i],
marker: {color: clr}
}
traces.push(temptrace);
}
var data = traces;
var layout = {
xaxis: {
title: 'SHAP value',
zeroline: false
}
};
Plotly.newPlot('boxDiv1', data,layout);
}
});
Could you please let me know what should be added to get my desired output
Via Active questions tagged javascript - Stack Overflow https://ift.tt/8K7hT25
Comments
Post a Comment