Skip to content

Commit

Permalink
Changed the code to use version specified dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronge-2020 committed Oct 27, 2023
1 parent 5bd780b commit 7f7e35b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 40 deletions.
82 changes: 44 additions & 38 deletions mSigSDKScripts/mSigPortalAPIs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
fetchURLAndCache,
} from "./utils.js";

//#region Mutational Signatures
import { fetchURLAndCache } from "./utils.js";

/**
//#region Mutational Signatures

/**
Retrieves the mutational signature options from the specified API endpoint.
@async
Expand Down Expand Up @@ -45,14 +43,13 @@ export async function getMutationalSignaturesData(
genomeDataType = "WGS",
signatureSetName = "COSMIC_v3_Signatures_GRCh37_SBS96",
mutationType = "SBS",
matrix = 96,
numberofResults = 10
) {
const url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/mutational_signature?
source=Reference_signatures&strategy=${genomeDataType}&profile=${mutationType}&matrix=96&signatureSetName=${signatureSetName}&limit=${numberofResults}&offset=0`;
source=Reference_signatures&strategy=${genomeDataType}&profile=${mutationType}&matrix=${matrix}&signatureSetName=${signatureSetName}&limit=${numberofResults}&offset=0`;
const cacheName = "getMutationalSignaturesData";
const unformattedData = await (
await fetchURLAndCache(cacheName, url)
).json();
const unformattedData = await (await fetchURLAndCache(cacheName, url)).json();
// const formattedData = extractMutationalSpectra(
// unformattedData,
// "signatureName"
Expand Down Expand Up @@ -138,22 +135,36 @@ export async function getMutationalSpectrumData(
const promises = [];
let urls = [];

if (cancerType == null) {
if (cancerType == '') {
let url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/mutational_spectrum?study=${study}&strategy=${genomeDataType}&profile=${mutationType}&matrix=${matrixSize}&offset=0`;

let unformattedData = await (
await fetchURLAndCache(cacheName, url)
).json();
let unformattedData = await (await fetchURLAndCache(cacheName, url)).json();

return unformattedData;
}

if (samples === null) {
let url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/mutational_spectrum?study=${study}&cancer=${cancerType}&strategy=${genomeDataType}&profile=${mutationType}&matrix=${matrixSize}&offset=0`;
let url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/mutational_spectrum?study=${study}`;

if (cancerType !== null) {
url += `&cancer=${cancerType}`;
}

if (genomeDataType !== null) {
url += `&strategy=${genomeDataType}`;
}

if (mutationType !== null) {
url += `&profile=${mutationType}`;
}

let unformattedData = await (
await fetchURLAndCache(cacheName, url)
).json();
if (matrixSize !== null) {
url += `&matrix=${matrixSize}`;
}

url += `&offset=0`;

let unformattedData = await (await fetchURLAndCache(cacheName, url)).json();
// let formattedData = extractMutationalSpectra(unformattedData, "sample");
return unformattedData;
} else {
Expand Down Expand Up @@ -300,13 +311,11 @@ export async function getMutationalSignatureActivityData(
cancerType = "",
numberOfResults = 10
) {
let url = '';
let url = "";
if (cancerType == "") {
url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_activity?study=${study}&strategy=${genomeDataType}&signatureSetName=${signatureSetName}&limit=${numberOfResults}&offset=0`;

}else{
} else {
url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_activity?study=${study}&strategy=${genomeDataType}&signatureSetName=${signatureSetName}&limit=${numberOfResults}&cancer=${cancerType}&offset=0`;

}

const cacheName = "getMutationalSignatureActivityData";
Expand All @@ -333,11 +342,10 @@ export async function getMutationalSignatureLandscapeData(
signatureSetName = "COSMIC_v3_Signatures_GRCh37_SBS96",
numberOfResults = 10
) {
let url = '';
let url = "";
if (cancerType == "") {
url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_activity?study=${study}&strategy=${genomeDataType}&signatureSetName=${signatureSetName}&limit=${numberOfResults}&offset=0`;

}else{
} else {
url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_activity?study=${study}&strategy=${genomeDataType}&signatureSetName=${signatureSetName}&limit=${numberOfResults}&cancer=${cancerType}&offset=0`;
}
const cacheName = "getMutationalSignatureLandscapeData";
Expand Down Expand Up @@ -375,24 +383,24 @@ export async function getMutationalSignatureEtiologyOptions(
cancerType = "",
numberOfResults = 10
) {

// Pass the arguments into the url of the api call only if they are not empty strings

let url = "https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_etiology_options?"

let url =
"https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_etiology_options?";

if (category != "") {
url += `category=${category}&`
url += `category=${category}&`;
}
if (etiology != "") {
url += `etiology=${etiology}&`
url += `etiology=${etiology}&`;
}
if (signatureName != "") {
url += `signature=${signatureName}&`
url += `signature=${signatureName}&`;
}
if (cancerType != "") {
url += `cancer=${cancerType}&`
url += `cancer=${cancerType}&`;
}
url += `limit=${numberOfResults}&offset=0`
url += `limit=${numberOfResults}&offset=0`;

const cacheName = "getMutationalSignatureEtiologyOptions";
return await (await fetchURLAndCache(cacheName, url)).json();
Expand All @@ -418,15 +426,13 @@ export async function getMutationalSignatureEtiologyData(
cancerType = "",
numberOfResults = 10
) {
let url = '';

let url = "";

if (cancerType == "") {
url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_etiology?study=${study}&strategy=${genomeDataType}&signatureName=${signatureName}&limit=${numberOfResults}&offset=0`;
}
else{
} else {
url = `https://analysistools-dev.cancer.gov/mutational-signatures/api/signature_etiology?study=${study}&strategy=${genomeDataType}&signatureName=${signatureName}&cancer=${cancerType}&limit=${numberOfResults}&offset=0`;
}
}

const cacheName = "getMutationalSignatureEtiologyData";
return await (await fetchURLAndCache(cacheName, url)).json();
Expand Down
4 changes: 2 additions & 2 deletions mSigSDKScripts/machineLearning.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as MLR from "https://cdn.jsdelivr.net/npm/ml-regression-multivariate-linear/+esm";
import * as MLR from "https://esm.sh/ml-regression-multivariate-linear@2.0.4";

import * as CV from "https://cdn.jsdelivr.net/npm/ml-cross-validation/+esm";
import * as CV from "https://esm.sh/ml-cross-validation@1.3.0";

import { groupBy } from "./utils.js";

Expand Down

0 comments on commit 7f7e35b

Please sign in to comment.