From 7fc22c74be98a492b283d3b6a17098590ead5616 Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 5 Aug 2025 13:41:41 -0700 Subject: [PATCH 01/17] Correct filename error --- .../{ApplyKnownClontypicData.R => ApplyKnownClonotypicData.R} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename singlecell/resources/chunks/{ApplyKnownClontypicData.R => ApplyKnownClonotypicData.R} (83%) diff --git a/singlecell/resources/chunks/ApplyKnownClontypicData.R b/singlecell/resources/chunks/ApplyKnownClonotypicData.R similarity index 83% rename from singlecell/resources/chunks/ApplyKnownClontypicData.R rename to singlecell/resources/chunks/ApplyKnownClonotypicData.R index d0bef4d07..f48447ea5 100644 --- a/singlecell/resources/chunks/ApplyKnownClontypicData.R +++ b/singlecell/resources/chunks/ApplyKnownClonotypicData.R @@ -11,7 +11,7 @@ for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) - seuratObj <- ApplyKnownClontypicData(seuratObj, groupFields = groupFields, addMetadata = addMetadata) + seuratObj <- ApplyKnownClonotypicData(seuratObj, groupFields = groupFields, addMetadata = addMetadata) saveData(seuratObj, datasetId) # Cleanup From 56c5fc4a68c1bd91fc13e07c991ed4bfe703f495 Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 5 Aug 2025 15:32:28 -0700 Subject: [PATCH 02/17] Allow greater curl timeout --- singlecell/resources/chunks/ApplyKnownClonotypicData.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/ApplyKnownClonotypicData.R b/singlecell/resources/chunks/ApplyKnownClonotypicData.R index f48447ea5..54e7831b8 100644 --- a/singlecell/resources/chunks/ApplyKnownClonotypicData.R +++ b/singlecell/resources/chunks/ApplyKnownClonotypicData.R @@ -4,7 +4,7 @@ if (!file.exists(netRc)) { stop(paste0('Unable to find file: ', netRc)) } -invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, connect-timeout = 10)) +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, 'connect-timeout' = 60)) Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) for (datasetId in names(seuratObjects)) { From 36e41761fa5ca7558dbfad9c6100fdcdfc0ad2ce Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 5 Aug 2025 16:13:23 -0700 Subject: [PATCH 03/17] Bugfix to ApplyKnownClonotypicData --- singlecell/resources/chunks/ApplyKnownClonotypicData.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/ApplyKnownClonotypicData.R b/singlecell/resources/chunks/ApplyKnownClonotypicData.R index 54e7831b8..7a16aa6f8 100644 --- a/singlecell/resources/chunks/ApplyKnownClonotypicData.R +++ b/singlecell/resources/chunks/ApplyKnownClonotypicData.R @@ -11,7 +11,7 @@ for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) - seuratObj <- ApplyKnownClonotypicData(seuratObj, groupFields = groupFields, addMetadata = addMetadata) + seuratObj <- ApplyKnownClonotypicData(seuratObj) saveData(seuratObj, datasetId) # Cleanup From d9dedddb2a8a1c0af9f759f074123837296911cd Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 5 Aug 2025 16:50:27 -0700 Subject: [PATCH 04/17] Bugfix to ApplyKnownClonotypicData --- singlecell/resources/chunks/ApplyKnownClonotypicData.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/ApplyKnownClonotypicData.R b/singlecell/resources/chunks/ApplyKnownClonotypicData.R index 7a16aa6f8..d73e4ef1e 100644 --- a/singlecell/resources/chunks/ApplyKnownClonotypicData.R +++ b/singlecell/resources/chunks/ApplyKnownClonotypicData.R @@ -4,7 +4,7 @@ if (!file.exists(netRc)) { stop(paste0('Unable to find file: ', netRc)) } -invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, 'connect-timeout' = 60)) +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc)) Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) for (datasetId in names(seuratObjects)) { From ed0fcdfa3641e3da7016c80600c95dbde0f4ec8b Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 5 Aug 2025 17:10:21 -0700 Subject: [PATCH 05/17] Try to extend RCurl timeout --- singlecell/resources/chunks/AppendMetadata.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/AppendMetadata.R b/singlecell/resources/chunks/AppendMetadata.R index f14a25f65..9e25ab85b 100644 --- a/singlecell/resources/chunks/AppendMetadata.R +++ b/singlecell/resources/chunks/AppendMetadata.R @@ -4,7 +4,7 @@ if (!file.exists(netRc)) { stop(paste0('Unable to find file: ', netRc)) } -invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc)) +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, timeout = 60, timeout_ms = 60000)) Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) for (datasetId in names(seuratObjects)) { From a48f6ee855d84bef2e4becd800dd5ad740c6de87 Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 5 Aug 2025 18:08:23 -0700 Subject: [PATCH 06/17] Second extension of RCurl timeout --- singlecell/resources/chunks/StudyMetadata.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/StudyMetadata.R b/singlecell/resources/chunks/StudyMetadata.R index b64a2c66e..1d0ecd02b 100644 --- a/singlecell/resources/chunks/StudyMetadata.R +++ b/singlecell/resources/chunks/StudyMetadata.R @@ -4,7 +4,7 @@ if (!file.exists(netRc)) { stop(paste0('Unable to find file: ', netRc)) } -invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc)) +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, timeout = 60, timeout_ms = 60000)) Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) for (datasetId in names(seuratObjects)) { From e5e9b85f3b5da8cbd6ec3ea0a4e760ed9d3e4428 Mon Sep 17 00:00:00 2001 From: bbimber Date: Wed, 6 Aug 2025 15:53:51 -0700 Subject: [PATCH 07/17] Increase curl timeout --- singlecell/resources/chunks/StudyMetadata.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/StudyMetadata.R b/singlecell/resources/chunks/StudyMetadata.R index 1d0ecd02b..e3415b71e 100644 --- a/singlecell/resources/chunks/StudyMetadata.R +++ b/singlecell/resources/chunks/StudyMetadata.R @@ -4,9 +4,16 @@ if (!file.exists(netRc)) { stop(paste0('Unable to find file: ', netRc)) } -invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, timeout = 60, timeout_ms = 60000)) +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, timeout = 60, timeout_ms = 60000, connecttimeout = 20, connecttimeout_ms = 20000)) Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) +curlOpt <- curl::curl_options('timeout') +message('Curl options:') +for (x in names(curlOpt)) { + message(paste0(x, ': ', curlOpt[x])) +} +rm(curlOpt) + for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) From 08405c760f3d00f50e2a04d041a6a510c5e18044 Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 7 Aug 2025 10:33:14 -0700 Subject: [PATCH 08/17] Prepare to support CalculateTcrRepertoireStats --- .../chunks/CalculateTcrRepertioreStats.R | 18 ++++++++ .../labkey/singlecell/SingleCellModule.java | 2 + .../CalculateTcrRepertoireStats.java | 43 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 singlecell/resources/chunks/CalculateTcrRepertioreStats.R create mode 100644 singlecell/src/org/labkey/singlecell/pipeline/singlecell/CalculateTcrRepertoireStats.java diff --git a/singlecell/resources/chunks/CalculateTcrRepertioreStats.R b/singlecell/resources/chunks/CalculateTcrRepertioreStats.R new file mode 100644 index 000000000..39ee96996 --- /dev/null +++ b/singlecell/resources/chunks/CalculateTcrRepertioreStats.R @@ -0,0 +1,18 @@ +netRc <- paste0(Sys.getenv('USER_HOME'), '/.netrc') +if (!file.exists(netRc)) { + print(list.files(Sys.getenv('USER_HOME'))) + stop(paste0('Unable to find file: ', netRc)) +} + +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc)) +Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) + +for (datasetId in names(seuratObjects)) { + printName(datasetId) + seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) + seuratObj <- Rdiscvr::CalculateAndStoreTcrRepertioreStats(seuratObj) + + # Cleanup + rm(seuratObj) + gc() +} \ No newline at end of file diff --git a/singlecell/src/org/labkey/singlecell/SingleCellModule.java b/singlecell/src/org/labkey/singlecell/SingleCellModule.java index e41e4980c..c5c17c964 100644 --- a/singlecell/src/org/labkey/singlecell/SingleCellModule.java +++ b/singlecell/src/org/labkey/singlecell/SingleCellModule.java @@ -45,6 +45,7 @@ import org.labkey.singlecell.pipeline.singlecell.ApplyKnownClonotypicData; import org.labkey.singlecell.pipeline.singlecell.AvgExpression; import org.labkey.singlecell.pipeline.singlecell.CalculateGeneComponentScores; +import org.labkey.singlecell.pipeline.singlecell.CalculateTcrRepertoireStats; import org.labkey.singlecell.pipeline.singlecell.CalculateUCellScores; import org.labkey.singlecell.pipeline.singlecell.CellBarcodeFilter; import org.labkey.singlecell.pipeline.singlecell.CheckExpectations; @@ -301,6 +302,7 @@ public static void registerPipelineSteps() SequencePipelineService.get().registerPipelineStep(new PerformMhcDimRedux.Provider()); SequencePipelineService.get().registerPipelineStep(new RunTricycle.Provider()); SequencePipelineService.get().registerPipelineStep(new ApplyKnownClonotypicData.Provider()); + SequencePipelineService.get().registerPipelineStep(new CalculateTcrRepertoireStats.Provider()); SequenceAnalysisService.get().registerReadsetListener(new SingleCellReadsetListener()); } diff --git a/singlecell/src/org/labkey/singlecell/pipeline/singlecell/CalculateTcrRepertoireStats.java b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/CalculateTcrRepertoireStats.java new file mode 100644 index 000000000..e802c342a --- /dev/null +++ b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/CalculateTcrRepertoireStats.java @@ -0,0 +1,43 @@ +package org.labkey.singlecell.pipeline.singlecell; + +import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStepProvider; +import org.labkey.api.sequenceanalysis.pipeline.PipelineContext; +import org.labkey.api.singlecell.pipeline.SingleCellStep; + +import java.util.Arrays; + +public class CalculateTcrRepertoireStats extends AbstractRDiscvrStep +{ + public CalculateTcrRepertoireStats(PipelineContext ctx, CalculateTcrRepertoireStats.Provider provider) + { + super(provider, ctx); + } + + public static class Provider extends AbstractPipelineStepProvider + { + public Provider() + { + super("CalculateTcrRepertoireStats", "Calculate TCR Repertoire Stats", "CellMembrane/tcrdist3", "This will calculate TCR diversity metrics, and save the results in the database.", Arrays.asList( + + ), null, null); + } + + @Override + public CalculateTcrRepertoireStats create(PipelineContext ctx) + { + return new CalculateTcrRepertoireStats(ctx, this); + } + } + + @Override + public boolean createsSeuratObjects() + { + return false; + } + + @Override + public String getFileSuffix() + { + return "ts"; + } +} From 62ba3a1b2cdc224a6e164a104a704f22bc8cbf45 Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 7 Aug 2025 10:44:14 -0700 Subject: [PATCH 09/17] Better handling of return from CalculateAndStoreTcrRepertioreStats --- singlecell/resources/chunks/CalculateTcrRepertioreStats.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/CalculateTcrRepertioreStats.R b/singlecell/resources/chunks/CalculateTcrRepertioreStats.R index 39ee96996..d8f2088eb 100644 --- a/singlecell/resources/chunks/CalculateTcrRepertioreStats.R +++ b/singlecell/resources/chunks/CalculateTcrRepertioreStats.R @@ -10,9 +10,10 @@ Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKe for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) - seuratObj <- Rdiscvr::CalculateAndStoreTcrRepertioreStats(seuratObj) + df <- Rdiscvr::CalculateAndStoreTcrRepertioreStats(seuratObj) # Cleanup rm(seuratObj) + rm(df) gc() } \ No newline at end of file From bb1eadc75fd7cc600ac27918f8da7a3ac539566b Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 7 Aug 2025 15:09:27 -0700 Subject: [PATCH 10/17] Add calculated column listing cohorts --- .../resources/queries/studies/studies/.qview.xml | 13 +++++++++++++ Studies/resources/schemas/studies.xml | 1 + .../labkey/studies/query/StudiesUserSchema.java | 14 +++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Studies/resources/queries/studies/studies/.qview.xml diff --git a/Studies/resources/queries/studies/studies/.qview.xml b/Studies/resources/queries/studies/studies/.qview.xml new file mode 100644 index 000000000..a694c9520 --- /dev/null +++ b/Studies/resources/queries/studies/studies/.qview.xml @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/Studies/resources/schemas/studies.xml b/Studies/resources/schemas/studies.xml index fd0d0a189..5dbd8d185 100644 --- a/Studies/resources/schemas/studies.xml +++ b/Studies/resources/schemas/studies.xml @@ -132,6 +132,7 @@ DETAILED + Study Id true false false diff --git a/Studies/src/org/labkey/studies/query/StudiesUserSchema.java b/Studies/src/org/labkey/studies/query/StudiesUserSchema.java index 715d4aa0c..e9d1b245a 100644 --- a/Studies/src/org/labkey/studies/query/StudiesUserSchema.java +++ b/Studies/src/org/labkey/studies/query/StudiesUserSchema.java @@ -7,12 +7,15 @@ import org.labkey.api.data.Container; import org.labkey.api.data.ContainerFilter; import org.labkey.api.data.DbSchema; +import org.labkey.api.data.JdbcType; +import org.labkey.api.data.SQLFragment; import org.labkey.api.data.SchemaTableInfo; import org.labkey.api.data.SimpleFilter; import org.labkey.api.data.TableInfo; import org.labkey.api.data.TableSelector; import org.labkey.api.ldk.table.ContainerScopedTable; import org.labkey.api.ldk.table.CustomPermissionsTable; +import org.labkey.api.query.ExprColumn; import org.labkey.api.query.FieldKey; import org.labkey.api.query.QueryDefinition; import org.labkey.api.query.QueryException; @@ -177,7 +180,16 @@ private TableInfo createStudyDesignTable(String name, ContainerFilter cf, boolea ret.addTriggerFactory(new StudiesTriggerFactory()); } - return ret.init(); + ret = ret.init(); + + final String chr = ret.getSqlDialect().isPostgreSQL() ? "chr" : "char"; + SQLFragment sql1 = new SQLFragment("(SELECT ").append(ret.getSqlDialect().getGroupConcat(new SQLFragment("c.label"), true, true, new SQLFragment(chr + "(10)"))).append(" as expr FROM " + StudiesSchema.NAME + "." + TABLE_COHORTS + " c WHERE c.studyId = " + ExprColumn.STR_TABLE_ALIAS + ".rowId)"); + ExprColumn col1 = new ExprColumn(ret, "cohorts", sql1, JdbcType.VARCHAR, ret.getColumn("rowid")); + col1.setLabel("Cohort(s)"); + col1.setDescription("This column lists the cohort labels for this study"); + ret.addColumn(col1); + + return ret; } private LookupSetTable createForPropertySet(StudiesUserSchema us, ContainerFilter cf, String setName, Map map) From 9615302ef90ee89051299fb10734c95fc83b0eef Mon Sep 17 00:00:00 2001 From: bbimber Date: Thu, 7 Aug 2025 17:42:54 -0700 Subject: [PATCH 11/17] Add study validation notification --- Studies/resources/views/studiesOverview.html | 3 +- .../studies/query/StudiesUserSchema.java | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Studies/resources/views/studiesOverview.html b/Studies/resources/views/studiesOverview.html index f257fc184..2d1d6a280 100644 --- a/Studies/resources/views/studiesOverview.html +++ b/Studies/resources/views/studiesOverview.html @@ -12,7 +12,7 @@ name: 'query', schemaName: 'studies', queryName: 'studies', - maxRows: 20 + maxRows: 10 }).render(webpart.wrapperDivId + '-studies'); // LABKEY.Query.selectRows({ @@ -62,4 +62,5 @@ }(jQuery, LABKEY)); +
Below is a list of the studies tracked in this folder. Please use the Data Browser tab to browse the dataset tracked in this project.
diff --git a/Studies/src/org/labkey/studies/query/StudiesUserSchema.java b/Studies/src/org/labkey/studies/query/StudiesUserSchema.java index e9d1b245a..928d882c6 100644 --- a/Studies/src/org/labkey/studies/query/StudiesUserSchema.java +++ b/Studies/src/org/labkey/studies/query/StudiesUserSchema.java @@ -1,5 +1,6 @@ package org.labkey.studies.query; +import com.google.gwt.user.client.ui.TabBar; import org.apache.logging.log4j.Logger; import org.labkey.api.collections.CaseInsensitiveHashMap; import org.labkey.api.collections.CaseInsensitiveTreeSet; @@ -137,7 +138,7 @@ else if (TABLE_LOOKUPS.equalsIgnoreCase(name)) } else if (TABLE_STUDIES.equalsIgnoreCase(name)) { - return createStudyDesignTable(name, cf, false); + return createStudiesTable(name, cf, false); } else if (TABLE_COHORTS.equalsIgnoreCase(name)) { @@ -168,7 +169,22 @@ else if (TABLE_EVENT_TYPES.equalsIgnoreCase(name)) return super.createTable(name, cf); } - private TableInfo createStudyDesignTable(String name, ContainerFilter cf, boolean addTriggers) + private TableInfo createStudiesTable(String name, ContainerFilter cf, boolean addTriggers) + { + CustomPermissionsTable ret = createStudyDesignTable(name, cf, addTriggers); + + final String chr = ret.getSqlDialect().isPostgreSQL() ? "chr" : "char"; + SQLFragment sql1 = new SQLFragment("(SELECT ").append(ret.getSqlDialect().getGroupConcat(new SQLFragment("c.label"), true, true, new SQLFragment(chr + "(10)"))).append(" as expr FROM " + StudiesSchema.NAME + "." + TABLE_COHORTS + " c WHERE c.studyId = " + ExprColumn.STR_TABLE_ALIAS + ".rowId)"); + ExprColumn col1 = new ExprColumn(ret, "cohorts", sql1, JdbcType.VARCHAR, ret.getColumn("rowid")); + col1.setLabel("Cohort(s)"); + col1.setDescription("This column lists the cohort labels for this study"); + + ret.addColumn(col1); + + return ret; + } + + private CustomPermissionsTable createStudyDesignTable(String name, ContainerFilter cf, boolean addTriggers) { CustomPermissionsTable ret = new CustomPermissionsTable<>(this, createSourceTable(name), cf); ret.addPermissionMapping(InsertPermission.class, StudiesDataAdminPermission.class); @@ -180,16 +196,7 @@ private TableInfo createStudyDesignTable(String name, ContainerFilter cf, boolea ret.addTriggerFactory(new StudiesTriggerFactory()); } - ret = ret.init(); - - final String chr = ret.getSqlDialect().isPostgreSQL() ? "chr" : "char"; - SQLFragment sql1 = new SQLFragment("(SELECT ").append(ret.getSqlDialect().getGroupConcat(new SQLFragment("c.label"), true, true, new SQLFragment(chr + "(10)"))).append(" as expr FROM " + StudiesSchema.NAME + "." + TABLE_COHORTS + " c WHERE c.studyId = " + ExprColumn.STR_TABLE_ALIAS + ".rowId)"); - ExprColumn col1 = new ExprColumn(ret, "cohorts", sql1, JdbcType.VARCHAR, ret.getColumn("rowid")); - col1.setLabel("Cohort(s)"); - col1.setDescription("This column lists the cohort labels for this study"); - ret.addColumn(col1); - - return ret; + return ret.init(); } private LookupSetTable createForPropertySet(StudiesUserSchema us, ContainerFilter cf, String setName, Map map) From 48cbfe37173e47beace2bccf4992ca564e604107 Mon Sep 17 00:00:00 2001 From: bbimber Date: Sat, 9 Aug 2025 07:26:16 -0700 Subject: [PATCH 12/17] Add PredictTcellActivation --- singlecell/resources/chunks/AppendMetadata.R | 9 ++++- .../resources/chunks/PredictTcellActivation.R | 12 ++++++ singlecell/resources/chunks/StudyMetadata.R | 4 +- .../labkey/singlecell/SingleCellModule.java | 2 + .../singlecell/PredictTcellActivation.java | 37 +++++++++++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 singlecell/resources/chunks/PredictTcellActivation.R create mode 100644 singlecell/src/org/labkey/singlecell/pipeline/singlecell/PredictTcellActivation.java diff --git a/singlecell/resources/chunks/AppendMetadata.R b/singlecell/resources/chunks/AppendMetadata.R index 9e25ab85b..d67d25fea 100644 --- a/singlecell/resources/chunks/AppendMetadata.R +++ b/singlecell/resources/chunks/AppendMetadata.R @@ -4,9 +4,16 @@ if (!file.exists(netRc)) { stop(paste0('Unable to find file: ', netRc)) } -invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, timeout = 60, timeout_ms = 60000)) +invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, timeout = 60, timeout_ms = 60000, connecttimeout = 20, connecttimeout_ms = 20000)) Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) +curlOpt <- curl::curl_options('timeout') +logger::log_info('Curl options:') +for (x in names(curlOpt)) { + logger::log_info(paste0(x, ': ', curlOpt[x])) +} +rm(curlOpt) + for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) diff --git a/singlecell/resources/chunks/PredictTcellActivation.R b/singlecell/resources/chunks/PredictTcellActivation.R new file mode 100644 index 000000000..704759380 --- /dev/null +++ b/singlecell/resources/chunks/PredictTcellActivation.R @@ -0,0 +1,12 @@ +for (datasetId in names(seuratObjects)) { + printName(datasetId) + seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) + + seuratObj <- PredictTcellActivation(seuratObj) + + saveData(seuratObj, datasetId) + + # Cleanup + rm(seuratObj) + gc() +} \ No newline at end of file diff --git a/singlecell/resources/chunks/StudyMetadata.R b/singlecell/resources/chunks/StudyMetadata.R index e3415b71e..f5fb694ff 100644 --- a/singlecell/resources/chunks/StudyMetadata.R +++ b/singlecell/resources/chunks/StudyMetadata.R @@ -8,9 +8,9 @@ invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc, timeout = 60, timeo Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) curlOpt <- curl::curl_options('timeout') -message('Curl options:') +logger::log_info('Curl options:') for (x in names(curlOpt)) { - message(paste0(x, ': ', curlOpt[x])) + logger::log_info(paste0(x, ': ', curlOpt[x])) } rm(curlOpt) diff --git a/singlecell/src/org/labkey/singlecell/SingleCellModule.java b/singlecell/src/org/labkey/singlecell/SingleCellModule.java index c5c17c964..def91fcd7 100644 --- a/singlecell/src/org/labkey/singlecell/SingleCellModule.java +++ b/singlecell/src/org/labkey/singlecell/SingleCellModule.java @@ -79,6 +79,7 @@ import org.labkey.singlecell.pipeline.singlecell.PlotAssayFeatures; import org.labkey.singlecell.pipeline.singlecell.PlotAverageCiteSeqCounts; import org.labkey.singlecell.pipeline.singlecell.PredictScTour; +import org.labkey.singlecell.pipeline.singlecell.PredictTcellActivation; import org.labkey.singlecell.pipeline.singlecell.PrepareRawCounts; import org.labkey.singlecell.pipeline.singlecell.RemoveCellCycle; import org.labkey.singlecell.pipeline.singlecell.RunCellHashing; @@ -303,6 +304,7 @@ public static void registerPipelineSteps() SequencePipelineService.get().registerPipelineStep(new RunTricycle.Provider()); SequencePipelineService.get().registerPipelineStep(new ApplyKnownClonotypicData.Provider()); SequencePipelineService.get().registerPipelineStep(new CalculateTcrRepertoireStats.Provider()); + SequencePipelineService.get().registerPipelineStep(new PredictTcellActivation.Provider()); SequenceAnalysisService.get().registerReadsetListener(new SingleCellReadsetListener()); } diff --git a/singlecell/src/org/labkey/singlecell/pipeline/singlecell/PredictTcellActivation.java b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/PredictTcellActivation.java new file mode 100644 index 000000000..f4e9fdf83 --- /dev/null +++ b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/PredictTcellActivation.java @@ -0,0 +1,37 @@ +package org.labkey.singlecell.pipeline.singlecell; + +import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStepProvider; +import org.labkey.api.sequenceanalysis.pipeline.PipelineContext; +import org.labkey.api.singlecell.pipeline.SingleCellStep; + +import java.util.List; + +public class PredictTcellActivation extends AbstractRDiscvrStep +{ + public PredictTcellActivation(PipelineContext ctx, PredictTcellActivation.Provider provider) + { + super(provider, ctx); + } + + public static class Provider extends AbstractPipelineStepProvider + { + public Provider() + { + super("PredictTcellActivation", "Predict T cell Activation", "RIRA", "This uses RIRA::PredictTcellActivation to predict TCR-triggered T cells", List.of(), null, null); + } + + + @Override + public PredictTcellActivation create(PipelineContext ctx) + { + return new PredictTcellActivation(ctx, this); + } + } + + @Override + public String getFileSuffix() + { + return "tca"; + } +} + From b04b6f4561fe980832ee12ff18c62dc5b711bbeb Mon Sep 17 00:00:00 2001 From: bbimber Date: Mon, 11 Aug 2025 10:56:51 -0700 Subject: [PATCH 13/17] Fix spelling --- ...culateTcrRepertioreStats.R => CalculateTcrRepertoireStats.R} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename singlecell/resources/chunks/{CalculateTcrRepertioreStats.R => CalculateTcrRepertoireStats.R} (88%) diff --git a/singlecell/resources/chunks/CalculateTcrRepertioreStats.R b/singlecell/resources/chunks/CalculateTcrRepertoireStats.R similarity index 88% rename from singlecell/resources/chunks/CalculateTcrRepertioreStats.R rename to singlecell/resources/chunks/CalculateTcrRepertoireStats.R index d8f2088eb..7d0a3ad0e 100644 --- a/singlecell/resources/chunks/CalculateTcrRepertioreStats.R +++ b/singlecell/resources/chunks/CalculateTcrRepertoireStats.R @@ -10,7 +10,7 @@ Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKe for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) - df <- Rdiscvr::CalculateAndStoreTcrRepertioreStats(seuratObj) + df <- Rdiscvr::CalculateAndStoreTcrRepertoireStats(seuratObj) # Cleanup rm(seuratObj) From 2a00a3647d5f714e332b17198050e262e6baad74 Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 12 Aug 2025 09:32:31 -0700 Subject: [PATCH 14/17] Fully qualify method --- singlecell/resources/chunks/PredictTcellActivation.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/PredictTcellActivation.R b/singlecell/resources/chunks/PredictTcellActivation.R index 704759380..7b18f1922 100644 --- a/singlecell/resources/chunks/PredictTcellActivation.R +++ b/singlecell/resources/chunks/PredictTcellActivation.R @@ -2,7 +2,7 @@ for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) - seuratObj <- PredictTcellActivation(seuratObj) + seuratObj <- RIRA::PredictTcellActivation(seuratObj) saveData(seuratObj, datasetId) From 9f9ba2dfb6ac34d997642a84abe1cd4aa166f5c4 Mon Sep 17 00:00:00 2001 From: bbimber Date: Sun, 17 Aug 2025 21:00:16 -0700 Subject: [PATCH 15/17] Expand UpdateSeuratPrototype --- .../chunks/CalculateTcrRepertoireStats.R | 4 +++- .../resources/chunks/UpdateSeuratPrototype.R | 20 +++++++++++++++++++ .../singlecell/UpdateSeuratPrototype.java | 12 +++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/CalculateTcrRepertoireStats.R b/singlecell/resources/chunks/CalculateTcrRepertoireStats.R index 7d0a3ad0e..a365c1bcb 100644 --- a/singlecell/resources/chunks/CalculateTcrRepertoireStats.R +++ b/singlecell/resources/chunks/CalculateTcrRepertoireStats.R @@ -10,7 +10,9 @@ Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKe for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) - df <- Rdiscvr::CalculateAndStoreTcrRepertoireStats(seuratObj) + + outputFile <- gsub(seuratObjects[[datasetId]], pattern = '.rds', replacement = '.tcrStats.txt') + df <- Rdiscvr::CalculateAndStoreTcrRepertoireStats(seuratObj, outputFile = outputFile) # Cleanup rm(seuratObj) diff --git a/singlecell/resources/chunks/UpdateSeuratPrototype.R b/singlecell/resources/chunks/UpdateSeuratPrototype.R index a30396d81..c22f7b27a 100644 --- a/singlecell/resources/chunks/UpdateSeuratPrototype.R +++ b/singlecell/resources/chunks/UpdateSeuratPrototype.R @@ -7,6 +7,12 @@ if (!file.exists(netRc)) { invisible(Rlabkey::labkey.setCurlOptions(NETRC_FILE = netRc)) Rdiscvr::SetLabKeyDefaults(baseUrl = serverBaseUrl, defaultFolder = defaultLabKeyFolder) +if (Sys.getenv('SEURAT_MAX_THREADS') != '') { + nCores <- Sys.getenv('SEURAT_MAX_THREADS') +} else { + nCores <- 1 +} + for (datasetId in names(seuratObjects)) { printName(datasetId) seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) @@ -34,6 +40,20 @@ for (datasetId in names(seuratObjects)) { seuratObj <- Rdiscvr::ClassifyTNKByExpression(seuratObj) } + if (saveRepertoireStats) { + seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) + outputFile <- gsub(seuratObjects[[datasetId]], pattern = '.rds', replacement = '.tcrStats.txt') + df <- Rdiscvr::CalculateAndStoreTcrRepertoireStats(seuratObj, outputFile = outFile) + } + + if (scoreActivation) { + seuratObj <- RIRA::PredictTcellActivation(seuratObj) + } + + if (recalculateUCells) { + seuratObj <- RIRA::CalculateUCellScores(seuratObj, storeRanks = FALSE, assayName = 'RNA', forceRecalculate = TRUE, ncores = nCores) + } + saveData(seuratObj, datasetId) # Cleanup diff --git a/singlecell/src/org/labkey/singlecell/pipeline/singlecell/UpdateSeuratPrototype.java b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/UpdateSeuratPrototype.java index f750cf2bf..0cbdbb1f8 100644 --- a/singlecell/src/org/labkey/singlecell/pipeline/singlecell/UpdateSeuratPrototype.java +++ b/singlecell/src/org/labkey/singlecell/pipeline/singlecell/UpdateSeuratPrototype.java @@ -49,6 +49,18 @@ public Provider() {{ put("checked", false); }}, false), + SeuratToolParameter.create("recalculateUCells", "Recalculate UCells", "If checked, RIRA::CalculateUCellScores will be re-run", "checkbox", new JSONObject() + {{ + put("checked", true); + }}, true), + SeuratToolParameter.create("saveRepertoireStats", "Save TCR Repertoire Stats", "If checked, Rdiscvr::CalculateAndStoreTcrRepertoireStats will be run", "checkbox", new JSONObject() + {{ + put("checked", true); + }}, true), + SeuratToolParameter.create("scoreActivation", "Score T Cell Activation", "If checked, RIRA::PredictTcellActivation will be run", "checkbox", new JSONObject() + {{ + put("checked", true); + }}, true), SeuratToolParameter.create("keepOriginal", "Keep Copy of Original File", "If checked, the original file will be copied with the file extension '.bk'", "checkbox", new JSONObject() {{ put("checked", false); From 962ddcc2436756f15f1fb461b6956030b3a125c9 Mon Sep 17 00:00:00 2001 From: bbimber Date: Mon, 18 Aug 2025 08:11:30 -0700 Subject: [PATCH 16/17] Bugfix to UpdateSeuratPrototype.R --- singlecell/resources/chunks/UpdateSeuratPrototype.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singlecell/resources/chunks/UpdateSeuratPrototype.R b/singlecell/resources/chunks/UpdateSeuratPrototype.R index c22f7b27a..f5b41a24b 100644 --- a/singlecell/resources/chunks/UpdateSeuratPrototype.R +++ b/singlecell/resources/chunks/UpdateSeuratPrototype.R @@ -43,7 +43,7 @@ for (datasetId in names(seuratObjects)) { if (saveRepertoireStats) { seuratObj <- readSeuratRDS(seuratObjects[[datasetId]]) outputFile <- gsub(seuratObjects[[datasetId]], pattern = '.rds', replacement = '.tcrStats.txt') - df <- Rdiscvr::CalculateAndStoreTcrRepertoireStats(seuratObj, outputFile = outFile) + df <- Rdiscvr::CalculateAndStoreTcrRepertoireStats(seuratObj, outputFile = outputFile) } if (scoreActivation) { From 7f09ed6c9e90d100730e9e8da124ee2a82797554 Mon Sep 17 00:00:00 2001 From: bbimber Date: Tue, 19 Aug 2025 12:43:22 -0700 Subject: [PATCH 17/17] Consider container when truncating data in AbstractDataDefinedTable --- .../src/org/labkey/studies/query/LookupSetTable.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Studies/src/org/labkey/studies/query/LookupSetTable.java b/Studies/src/org/labkey/studies/query/LookupSetTable.java index b333008f3..022fc5802 100644 --- a/Studies/src/org/labkey/studies/query/LookupSetTable.java +++ b/Studies/src/org/labkey/studies/query/LookupSetTable.java @@ -22,7 +22,6 @@ import org.labkey.api.ldk.LDKService; import org.labkey.api.ldk.table.AbstractDataDefinedTable; import org.labkey.api.query.QueryUpdateService; -import org.labkey.api.query.SimpleUserSchema; import java.util.Map; @@ -101,15 +100,7 @@ public LookupSetTable init() @Override public QueryUpdateService getUpdateService() { - return new EHRLookupsUpdateService(this); - } - - protected class EHRLookupsUpdateService extends UpdateService - { - public EHRLookupsUpdateService(SimpleUserSchema.SimpleTable ti) - { - super(ti); - } + return new UpdateService(this); } }