Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
noatgnu committed Nov 27, 2024
1 parent 29916b8 commit 72a367e
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 109 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
<body>
<app-root></app-root>
<noscript>Please enable JavaScript to continue using this application.</noscript>
<link rel="modulepreload" href="chunk-6DCVN2GH.js"><script src="polyfills-LQM4VRV3.js" type="module"></script><script src="scripts-TSGU23AO.js" defer></script><script src="main-FXIOHAAQ.js" type="module"></script></body>
<link rel="modulepreload" href="chunk-6DCVN2GH.js"><script src="polyfills-LQM4VRV3.js" type="module"></script><script src="scripts-TSGU23AO.js" defer></script><script src="main-FIBIWZER.js" type="module"></script></body>
</html>
206 changes: 103 additions & 103 deletions docs/main-FXIOHAAQ.js → docs/main-FIBIWZER.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/ngsw.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"configVersion": 1,
"timestamp": 1732624879111,
"timestamp": 1732720805940,
"index": "/index.html",
"assetGroups": [
{
Expand All @@ -15,7 +15,7 @@
"/chunk-KT2VBPDM.js",
"/favicon.ico",
"/index.html",
"/main-FXIOHAAQ.js",
"/main-FIBIWZER.js",
"/manifest.webmanifest",
"/polyfills-LQM4VRV3.js",
"/scripts-TSGU23AO.js",
Expand Down Expand Up @@ -123,8 +123,8 @@
"/chunk-6DCVN2GH.js": "066732cf764f113fdd1354b5d694386dde1aa957",
"/chunk-KT2VBPDM.js": "513f86e4667b74dc3cbfe0b7141fe6921312b216",
"/favicon.ico": "22f6a4a3bcaafafb0254e0f2fa4ceb89e505e8b2",
"/index.html": "37b2c83386b522ec2321e478e42a7b1f7282c4a8",
"/main-FXIOHAAQ.js": "40099b840313b69544a22664c1b1ccdf7aff3b32",
"/index.html": "c7afe04ddabafbefce41eff76115a74e041af508",
"/main-FIBIWZER.js": "bf5e38aa34116cce2c55935e3582a585823e92d8",
"/manifest.webmanifest": "0f6d8f1c753e9f503daf4cd303ebecc6b0b0a04b",
"/polyfills-LQM4VRV3.js": "86507a9fae516c507974df2133f98fd48b561462",
"/scripts-TSGU23AO.js": "e172440274ca0257fbf1b7e414f5bd41b03b202f",
Expand Down
1 change: 0 additions & 1 deletion src/app/components/file-form/file-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class FileFormComponent implements OnInit {
startWork() {
this.finished.emit(false)
if (typeof Worker !== 'undefined') {
console.log("start worker")
// Create a new
const worker = new Worker(new URL('./data.worker', import.meta.url));
worker.onmessage = (data: MessageEvent<any>) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="modal-header">
<div class="modal-title">
Assign Colors by Category
</div>
</div>
<div class="modal-body">
@if (data) {
<form [formGroup]="form">
<div>
<label>Categorical value column</label>
<select class="form-control" formControlName="selectedColumn">
@for (o of data.getColumnNames(); track o) {
<option [value]="o">{{o}}</option>
}
</select>
</div>
</form>
}


@for (c of categories; track c) {
<div>
<div class="form-group">
<label for="color{{c}}">Color for {{c}}</label>
<input [(ngModel)]="categoryMap[c].color" [(colorPicker)]="categoryMap[c].color" class="form-control" [style.background-color]="categoryMap[c].color">
<small class="text-muted">Count: {{categoryMap[c].count}}</small>
<button type="button" class="btn btn-danger" (click)="removeGroup(c)"><i class="bi bi-trash"></i></button>
</div>
</div>

}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" (click)="close()">Cancel</button>
<button type="button" class="btn btn-primary" (click)="submit()">Apply</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ColorByCategoryModalComponent } from './color-by-category-modal.component';

describe('ColorByCategoryModalComponent', () => {
let component: ColorByCategoryModalComponent;
let fixture: ComponentFixture<ColorByCategoryModalComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ColorByCategoryModalComponent]
})
.compileComponents();

fixture = TestBed.createComponent(ColorByCategoryModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {Component, Input} from '@angular/core';
import {DataFrame, IDataFrame} from "data-forge";
import {FormBuilder, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";
import {ColorPickerModule} from "ngx-color-picker";

@Component({
selector: 'app-color-by-category-modal',
imports: [
ReactiveFormsModule,
FormsModule,
ColorPickerModule
],
templateUrl: './color-by-category-modal.component.html',
styleUrl: './color-by-category-modal.component.scss'
})
export class ColorByCategoryModalComponent {
@Input() data: IDataFrame = new DataFrame()
@Input() primaryIDColumn: string = ""
@Input() comparisonCol: string = ""

form = this.fb.group({
selectedColumn: ['', Validators.required],
})

categoryMap: any = {}
categories: string[] = []
constructor(private fb: FormBuilder, private activeModal: NgbActiveModal) {
this.form.controls.selectedColumn.valueChanges.subscribe((value) => {
if (value && this.data) {
this.data.forEach((row) => {
const primaryID = row[this.primaryIDColumn]
const comparison = "1"
if (row[this.comparisonCol]) {
const comparison: string = row[this.comparisonCol]
}
const category = row[value]
const title = `${value} ${category} (${comparison})`
if (!this.categoryMap[title]) {
this.categoryMap[title] = {
count: 1,
color: "",
comparison: comparison,
primaryIDs: [primaryID]
}
} else {
this.categoryMap[title].count++
this.categoryMap[title].primaryIDs.push(primaryID)
}
})
this.categories = Object.keys(this.categoryMap)
}
})
}

close() {
this.activeModal.dismiss()
}

submit() {
if (this.form.invalid) {
return
}
this.activeModal.close({
column: this.form.controls.selectedColumn.value,
categoryMap: this.categoryMap
})
}

removeGroup(category: string) {
delete this.categoryMap[category]
this.categories = Object.keys(this.categoryMap)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ <h2 class="accordion-header">
<button ngbDropdownItem (click)="FDRCurveSettings()">Custom FDR Curve</button>
<button ngbDropdownItem (click)="openCustomColor()">Custom Legend Color</button>
<button ngbDropdownItem (click)="openTextEditor()">Annotation Text Editor</button>
<button ngbDropdownItem (click)="openColorByCategoryModal()">Color By Category Column</button>
<button ngbDropdownItem (click)="clear()">Clear Selections</button>
<!--<button ngbDropdownItem (click)="download()">Download SVG</button>
-->
Expand Down
31 changes: 31 additions & 0 deletions src/app/components/volcano-plot/volcano-plot.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {ToastService} from "../../toast.service";
import {FormBuilder} from "@angular/forms";
import {AreYouSureClearModalComponent} from "../are-you-sure-clear-modal/are-you-sure-clear-modal.component";
import {ColorByCategoryModalComponent} from "./color-by-category-modal/color-by-category-modal.component";

@Component({
selector: 'app-volcano-plot',
Expand Down Expand Up @@ -104,6 +105,7 @@ export class VolcanoPlotComponent implements OnInit {
markerSize: number = 10
specialColorMap: any = {}
repeat = false

drawVolcano() {
this.currentPosition = 0
this.settings.settings.scatterPlotMarkerSize = this.markerSize
Expand Down Expand Up @@ -955,4 +957,33 @@ export class VolcanoPlotComponent implements OnInit {
this.drawVolcano()
console.log(this.graphLayout.shapes)
}

openColorByCategoryModal() {
const ref = this.modal.open(ColorByCategoryModalComponent, {scrollable: true})
ref.componentInstance.data = this.dataService.currentDF
ref.componentInstance.primaryIDColumn = this.dataService.differentialForm.primaryIDs
ref.componentInstance.comparisonCol = this.dataService.differentialForm.comparison
ref.closed.subscribe((data: {column: string, categoryMap: {[key: string]: {count: number, color: string, primaryIDs: string[], comparison: string}}}) => {
if (data) {
console.log(data)
for (const c in data.categoryMap) {
if (!this.dataService.selectOperationNames.includes(c)) {
this.dataService.selectOperationNames.push(c)
}
this.settings.settings.colorMap[c] = data.categoryMap[c].color
for (const p of data.categoryMap[c].primaryIDs) {
if (!this.dataService.selectedMap[p]) {
this.dataService.selectedMap[p] = {}
}
this.dataService.selectedMap[p][c] = true

}
console.log(this.dataService.selectedMap)
}

this.drawVolcano()
}
})
}

}

0 comments on commit 72a367e

Please sign in to comment.