Skip to content

Commit

Permalink
data push
Browse files Browse the repository at this point in the history
  • Loading branch information
samhimes92 committed Sep 18, 2023
1 parent 2b2aca3 commit b3d2c77
Show file tree
Hide file tree
Showing 35 changed files with 12,785 additions and 6,373 deletions.
Binary file modified data/.DS_Store
Binary file not shown.
6,146 changes: 6,145 additions & 1 deletion data/19919_alphas.json → data/current_runs.csv

Large diffs are not rendered by default.

6,144 changes: 6,144 additions & 0 deletions data/current_runs_old.csv

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions data/test_csv.csv

This file was deleted.

1 change: 0 additions & 1 deletion data/volcano_data/pcDNA3.1_vs_GPR162_high_.json

This file was deleted.

47 changes: 22 additions & 25 deletions js/alpha.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Alpha{
constructor(all_data,globalApplicationState,volcano){
constructor(all_data,globalApplicationState,volcano, h){


//**********************************************************************************************
// CONSTANTS
Expand Down Expand Up @@ -27,6 +28,7 @@ class Alpha{
this.globalApplicationState = globalApplicationState

this.all_data = all_data
this.h = h

this.volcano = volcano
this.alpha_div = d3.select("#alpha-div")
Expand Down Expand Up @@ -70,9 +72,6 @@ class Alpha{
// SELECTORS
//**********************************************************************************************




//For getting unique values for base a stimulated
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
Expand Down Expand Up @@ -146,7 +145,6 @@ class Alpha{
d3.select("#control_check").property('checked', false)
that.drawAlphaScatter()
that.points.selectAll("circle")
// .style("opacity", d => (+d[that.max_rank_name] <= 5) )
.filter(d => +d[that.max_rank_name] > n | d[that.max_rank_name] == "")
.remove();
}
Expand Down Expand Up @@ -245,7 +243,7 @@ class Alpha{
// Get inititial min and max for scales (Will change upon selection)
//***************************************

this.min = 0
this.min = -.5
this.max = 5

this.x_scale = d3.scaleLinear()
Expand All @@ -271,7 +269,8 @@ class Alpha{
.attr("id", "base_text")
.attr("transform","translate(" + this.WIDTH / 2 + " ," + (this.HEIGHT - 10) + ")")
.style("text-anchor", "middle")
.text("Basal Alpha");
.text("Basal Alpha")
.style('fill', '#6C4343');

this.alphaSvg
.append("text")
Expand All @@ -280,7 +279,8 @@ class Alpha{
.attr("y", 15)
.attr("x",-(this.HEIGHT/2))
.style("text-anchor", "middle")
.text("Stimulated Alpha");
.text("Stimulated Alpha")
.style('fill', '#00429d');


this.alphaSvg
Expand Down Expand Up @@ -342,8 +342,6 @@ class Alpha{

d3.selectAll('.child-div').style("opacity", "1").style("pointer-events", "all")



//Remove everything before drawing again
this.points
.selectAll('circle')
Expand All @@ -358,9 +356,8 @@ class Alpha{
this.stim_name = "alpha__"+stim_treatment+"__"+stim_run
this.base_name = "alpha__"+base_treatment+"__"+base_run
this.max_rank_name = "maxRank__" +base_treatment+"__"+base_run+"_vs_"+stim_treatment+"__"+stim_run
let max_name = "max__" +base_treatment+"__"+base_run+"_vs_"+stim_treatment+"__"+stim_run
let logFC_col = "logFC__"+this.globalApplicationState.selected_comparison
let pval_col = "statistic__"+this.globalApplicationState.selected_comparison
this.n_rna_stim_name = "RNA_barcodes__" +stim_treatment+"__"+stim_run
this.n_rna_base_name = "RNA_barcodes__" +base_treatment+"__"+base_run


d3.select("#base_text").text("Basal Alpha "+base_treatment + " ("+ base_run +")")
Expand All @@ -369,21 +366,21 @@ class Alpha{
this.globalApplicationState.selected_comparison = base_treatment+"__"+base_run+"_vs_"+stim_treatment+"__"+stim_run

const that = this
let selected_data = this.all_data.filter(function(d){return d[that.base_name]!= "";})
selected_data = selected_data.filter(function(d){return d[that.stim_name] != "";})


//Filter the same way we filter volcano data so all points are in each
selected_data = selected_data.filter(function(d){return d[pval_col]!= "";})
selected_data = selected_data.filter(function(d){return d[logFC_col] != "";})

this.globalApplicationState.motifs = [...new Set(selected_data.map((item) => item.motif))];
let filter_res = this.h.filter_comparison_data(
this.all_data,
base_treatment,
stim_treatment,
base_run,
stim_run,
selected_motif,
this.globalApplicationState.min_RNA,
this.globalApplicationState.min_DNA)

let selected_data = filter_res[0]
this.globalApplicationState.motifs = filter_res[1]

if (selected_motif != ""){
selected_data = selected_data.filter(function(d){return d.motif == selected_motif})
}


let max_base = d3.max(selected_data.map(d => +d[this.base_name]))
let max_stim = d3.max(selected_data.map(d => +d[this.stim_name]))

Expand Down
64 changes: 64 additions & 0 deletions js/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const helpers = {
filter_comparison_data: function(all_data, base_treatment, stim_treatment, base_run, stim_run, selected_motif, min_RNA, min_DNA){
//Takes all the data from for alpha/volcano and filters it.
//Returns filtered data frame.

let selected_comparison = base_treatment+"__"+base_run+"_vs_"+stim_treatment+"__"+stim_run
let stim_name = "alpha__"+stim_treatment+"__"+stim_run
let base_name = "alpha__"+base_treatment+"__"+base_run
let n_rna_stim_name = "RNA_barcodes__" +stim_treatment+"__"+stim_run
let n_rna_base_name = "RNA_barcodes__" +base_treatment+"__"+base_run
let n_dna_stim_name = "DNA_barcodes__" +stim_treatment+"__"+stim_run
let n_dna_base_name = "DNA_barcodes__" +base_treatment+"__"+base_run
let logFC_col = "logFC__"+selected_comparison
let pval_col = "statistic__"+selected_comparison
let statistic_name = "statistic__"+selected_comparison

//Make sure that the log fc and pval are there
//For some architectures MPRAnalyze doesn't call an alpha or fc
//We don't want those
let selected_data = all_data.filter(function(d){return d[base_name]!= "";})
selected_data = selected_data.filter(function(d){return d[stim_name] != "";})
selected_data = selected_data.filter(function(d){return d[pval_col]!= "";})
selected_data = selected_data.filter(function(d){return d[logFC_col] != "";})

//Filter for DNA and RNA counts
selected_data = selected_data.filter(function(d){return Math.floor(d[n_rna_stim_name]) >= Math.ceil(min_RNA)})
selected_data = selected_data.filter(function(d){return Math.floor(d[n_rna_base_name]) >= Math.ceil(min_RNA)})
selected_data = selected_data.filter(function(d){return Math.floor(d[n_dna_stim_name]) >= Math.ceil(min_DNA)})
selected_data = selected_data.filter(function(d){return Math.floor(d[n_dna_base_name]) >= Math.ceil(min_DNA)})

//Get max and min statistics before filtering for motif
let max_statistic = d3.max(selected_data.map(d => +d[statistic_name]))
let min_statistic = d3.min(selected_data.map(d => +d[statistic_name]))

let log_fold_changes = selected_data.map(d => d[logFC_col])
let max_fc = d3.max(log_fold_changes.map(d=> Number(d)))
let min_fc = d3.min(log_fold_changes.map(d=> Number(d)))

if (min_statistic >= 0){
min_statistic = 0
}
else{ //Get the lower quartile
min_statistic = d3.max([-(.2*max_statistic), min_statistic])
}

//Cut off anything that will dip below the min pval
selected_data = selected_data.filter(function(d){return d[statistic_name]>=min_statistic;})
let motifs = [...new Set(selected_data.map((item) => item.motif))];


// If there is a highlighted motif, filter for it.
if (selected_motif != ""){
selected_data = selected_data.filter(function(d){return d.motif == selected_motif})
}

return [selected_data, motifs, max_statistic, min_statistic, max_fc, min_fc]



}

}

export default helpers;
Loading

0 comments on commit b3d2c77

Please sign in to comment.