Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #138 from tsheils/development
Browse files Browse the repository at this point in the history
fix pathway analysis download
  • Loading branch information
tsheils authored Apr 17, 2024
2 parents 86c2e95 + 3bac001 commit 5e2552b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,9 @@ export class PathwayEnrichmentComponent
} else {
data = this.enrichedDataframe as unknown[]
}
const fff = new FisherResult(data[0] as Partial<FisherResult>)
this._downloadFile(
this._toTSV(data),
this._toTSV(data, fff._getFields()),
'fetchEnrichedPathwaysFromAnalytes-download.tsv',
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ <h3>Gene Overlap</h3>
Citation
</div>
<div class="section-content">
<p>
<!-- <p>
Our most current preprint is available
<a
href="https://www.biorxiv.org/content/10.1101/2022.01.19.476987v1"
Expand All @@ -470,7 +470,7 @@ <h3>Gene Overlap</h3>
aria-label="link to Updated RaMP-DB 2 preprint."
>here.</a
>
</p>
</p>-->
<p>If you use RaMP, please cite the following work:</p>
<p>
<a
Expand Down
3 changes: 2 additions & 1 deletion libs/models/ramp-models/src/lib/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { ChemicalEnrichment } from './chemical-enrichment';
import { FisherResult, FishersDataframe } from './fisher-result';
import { RampQuery } from './ramp-query';

export class RampDataGeneric {}
export class RampDataGeneric {
}

export interface RampAPIResponse<T extends RampDataGeneric> {
data: Array<T>;
Expand Down
6 changes: 5 additions & 1 deletion libs/models/ramp-models/src/lib/fisher-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FisherResult {
pathwayName!: string;
pathwaySource!: string;
pathwayId!: string;
cluster_assignment?: number;
cluster_assignment?: string;
metabCount!: string;
geneCount!: string;
pathCount!: string;
Expand All @@ -46,4 +46,8 @@ export class FisherResult {
this.pathCount = obj.Num_In_Path + '/' + obj.Total_In_Path;
}
}

_getFields() {
return Object.keys(this).filter(field => !['Total_In_Path', 'Pval_Holm', 'Pval_FDR', 'Pval', 'Num_In_Path', 'metabCount', 'geneCount', 'pathCount'].includes(field));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,27 @@ export class PageCoreComponent {
.subscribe();
}

_toTSV<T extends RampDataGeneric>(data: unknown[]): string {
_toTSV<T extends RampDataGeneric>(data: unknown[], fields?: string[]): string {
if (data) {
// grab the column headings (separated by tabs)
const headings: string = Object.keys(data[0] as string[]).join('\t');
const headings: string[] = fields ? fields : Object.keys(data[0] as string[]);
// iterate over the data
const rows: string[] = <string[]>data.reduce(
(acc: string[], c: unknown) => {
const ret = headings.map(field => {
if((c as T)[field as keyof T]) {
return (c as T)[<string>field as keyof T]
} else {
return
}
})
// for each row object get its values and add tabs between them
// then add them as a new array to the outgoing array
return acc.concat([Object.values(c as T).join('\t')]);
return acc.concat(ret.join('\t'));

// finally joining each row with a line break
},
[headings],
[headings.join('\t')],
);
return rows.join('\n');
} else return '';
Expand Down
2 changes: 1 addition & 1 deletion libs/stores/ramp-store/src/lib/+state/ramp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export class RampService {
(obj: unknown) => new FisherResult(obj as Partial<FisherResult>),
),
query: {},
combinedFishersdataframe: response.data as FishersDataframe,
combinedFishersDataframe: response.data as FishersDataframe,
} as RampPathwayEnrichmentResponse;
}),
// catchError(this.handleError('chemical enrichment', [])),
Expand Down

0 comments on commit 5e2552b

Please sign in to comment.