Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
plugins
GSEA
Commits
887804e9
Commit
887804e9
authored
Jul 11, 2019
by
Marek Ostaszewski
Browse files
Merge branch 'export' into 'master'
export to json and tsv See merge request
!3
parents
36ec85c5
53f00979
Pipeline
#11646
passed with stages
in 1 minute and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/js/index.js
View file @
887804e9
...
...
@@ -112,6 +112,11 @@ function getContainerClass() {
function
initMainContainer
(){
const
container
=
$
(
`<div class="
${
getContainerClass
()}
"></div>`
).
appendTo
(
pluginContainer
);
container
.
append
(
`
<div class="modal fade modal-container" role="dialog">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div class="panel panel-default gsea-pw-loading">
<div class="panel-body">
<i class="fa fa-circle-o-notch fa-spin"></i> Obtaining pathway-gene mapping from the map
...
...
@@ -301,6 +306,14 @@ function calculateGSEA() {
});
});
const
dataForExport
=
{
overlays
:
globals
.
overlayNames
,
mapProjectId
:
minervaProxy
.
project
.
data
.
getProjectId
(),
mapApi
:
ServerConnector
.
getApiBaseUrl
(),
data
:
[]
};
Object
.
keys
(
globals
.
ModelPathway
).
forEach
(
modelId
=>
{
let
pVals
=
Object
.
keys
(
globals
.
ModelPathway
[
modelId
])
...
...
@@ -335,6 +348,7 @@ function calculateGSEA() {
const
$table
=
$mapResultsPanel
.
find
(
'
table
'
);
const
exportVals
=
[];
pVals
.
sort
(
function
(
a
,
b
)
{
return
a
.
adjustedPVal
-
b
.
adjustedPVal
;
...
...
@@ -348,6 +362,7 @@ function calculateGSEA() {
const
pwName
=
p
.
pw
.
bioEntities
[
0
].
getName
();
$table
.
append
(
`<tr><td class="first-column">
${
pValText
}
</td><td>
${
pwName
}
</td></tr>`
);
exportVals
.
push
({
enrichedArea
:
pwName
,
adjustedPVal
:
p
.
adjustedPVal
});
p
.
pw
.
bioEntities
.
forEach
(
e
=>
{
highlightPathways
.
push
({
...
...
@@ -365,8 +380,13 @@ function calculateGSEA() {
});
});
dataForExport
.
data
.
push
({
mapName
:
mapName
,
areas
:
exportVals
})
});
addExport
(
pluginContainer
.
find
(
'
.gsea-results
'
),
dataForExport
);
minervaProxy
.
project
.
map
.
showBioEntity
(
highlightPathways
);
});
...
...
@@ -457,4 +477,105 @@ function calculateGSEA() {
// gsea_html += '</table>';
// pluginContainer.find('.panel-events .panel-body').html(gsea_html);
// });
}
function
addExport
(
$container
,
data
){
$container
.
append
(
$
(
`<div class="row">
<div class="col-sm-12">
<button type="button" class="btn-calc btn btn-success btn-default btn-block">Export</button>
</div>
</div>`
));
$container
.
find
(
"
button
"
).
on
(
"
click
"
,
()
=>
exportData
(
data
,
$container
));
}
const
exportData
=
function
(
data
,
$container
)
{
openModal
({
body
:
'
<button type="button" class="btn btn-block ceButtonExportJSON">JSON</button>
'
+
'
<button type="button" class="btn btn-block ceButtonExportTSV">TSV</button>
'
});
pluginContainer
.
find
(
'
.ceButtonExportJSON
'
).
on
(
'
click
'
,
()
=>
exportToFormat
(
'
json
'
,
data
,
$container
));
pluginContainer
.
find
(
'
.ceButtonExportTSV
'
).
on
(
'
click
'
,
()
=>
exportToFormat
(
'
tsv
'
,
data
,
$container
));
};
const
exportToFormat
=
function
(
format
,
data
,
$container
)
{
let
exportString
;
if
(
format
===
"
json
"
)
exportString
=
exportToJson
(
data
);
if
(
format
===
"
tsv
"
)
exportString
=
exportToTsv
(
data
);
let
fileName
=
'
export.
'
+
format
;
let
blob
=
new
Blob
([
exportString
],
{
type
:
'
text/
'
+
format
+
'
;charset=utf-8;
'
});
if
(
navigator
.
msSaveBlob
)
{
// IE 10+
navigator
.
msSaveBlob
(
blob
,
fileName
);
}
else
{
let
link
=
document
.
createElement
(
"
a
"
);
if
(
link
.
download
!==
undefined
)
{
// feature detection
// Browsers that support HTML5 download attribute
const
url
=
URL
.
createObjectURL
(
blob
);
link
.
setAttribute
(
"
href
"
,
url
);
link
.
setAttribute
(
"
download
"
,
fileName
);
link
.
style
.
visibility
=
'
hidden
'
;
document
.
body
.
appendChild
(
link
);
link
.
click
();
document
.
body
.
removeChild
(
link
);
}
}
closeModal
();
};
function
closeModal
()
{
pluginContainer
.
find
(
"
.modal-container
"
).
modal
(
"
hide
"
);
}
function
openModal
(
params
)
{
let
modal
=
pluginContainer
.
find
(
"
.modal-container
"
);
let
modalContent
=
modal
.
find
(
"
.modal-content
"
);
modalContent
.
empty
();
let
modalContentClass
=
"
modal-content
"
;
if
(
"
modalClass
"
in
params
)
modalContentClass
+=
"
"
+
params
.
modalClass
;
modalContent
.
attr
(
"
class
"
,
modalContentClass
);
if
(
"
header
"
in
params
)
{
let
header
=
pluginContainer
.
find
(
'
<div class="modal-header panel-heading"></div>
'
).
appendTo
(
modalContent
);
header
.
append
(
'
<button type="button" class="close">×</button>
'
);
header
.
append
(
'
<h4>
'
+
params
.
header
+
'
</h4>
'
);
}
if
(
"
body
"
in
params
)
{
let
body
=
$
(
'
<div class="modal-body"></div>
'
).
appendTo
(
modalContent
);
body
.
append
(
params
.
body
);
}
// ' <div class="modal-footer">' +
// ' <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>' +
// ' </div>' +
modal
.
modal
(
"
show
"
);
}
function
exportToTsv
(
data
)
{
let
res
=
`# overlays:
${
data
.
overlays
}
; mainMapProjectName:
${
data
.
mainMapProjectName
}
; mainMapProjectId:
${
data
.
mainMapProjectId
}
; mainMapApi:
${
data
.
mainMapApi
}
,mapProjectName:
${
data
.
mapProjectName
}
; mapProjectId:
${
data
.
mapProjectId
}
; mapApi:
${
data
.
mapApi
}
\n`
;
for
(
let
i
=
0
;
i
<
data
.
data
.
length
;
++
i
)
{
res
+=
`
${
data
.
data
[
i
].
mapName
}
\n`
;
res
+=
'
"p-val (adj)"
\t
"Enriched area"
\n
'
;
const
areas
=
data
.
data
[
i
].
areas
;
for
(
let
j
=
0
;
j
<
areas
.
length
;
++
j
)
{
res
+=
`"
${
areas
[
j
].
enrichedArea
}
"\t"
${
areas
[
j
].
adjustedPVal
}
"\n`
}
res
+=
'
\n
'
}
return
res
;
}
function
exportToJson
(
data
)
{
return
JSON
.
stringify
(
data
,
null
,
2
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment