Skip to content

Commit

Permalink
Merge pull request #606 from TheJacksonLaboratory/fix_disease_databas…
Browse files Browse the repository at this point in the history
…es_bug

Fix pretest probability calculation.
  • Loading branch information
ielis authored Apr 7, 2023
2 parents d71ebdf + 7282b29 commit bfcfef7
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ v2.0.0 (TBD)
- Enhance HTML report, add `JSON` output format
- Add ``prioritize`` command for running LIRICAL entirely from CLI
- Add support for phenopacket schema ``v2``
- Host documentation and API docs on github.io

-------------------
v1.3.3 (2021-05-14)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# LIRICAL
LIRICAL (LIkelihood Ratio Interpretation of Clinical AbnormaLities)
is designed to provide clinically interpretable computational analysis of phenotypic
abnormalities (encoded using the [Human Phenotype Ontology](http://www.human-phenotyope-ontology.org)),
abnormalities (encoded using the [Human Phenotype Ontology](http://www.human-phenotype-ontology.org)),
optionally combined with an analysis of variants and genotypes if a VCF file is provided with the
results of diagnostic gene panel, exome, or genome sequencing.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ private void setupLoggingAndPrintBanner() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.getLogger(Logger.ROOT_LOGGER_NAME).setLevel(level);

if (!(level.equals(Level.WARN) || level.equals(Level.ERROR)))
printBanner();
printBanner();
}

private static String readBanner() {
Expand All @@ -59,10 +58,9 @@ private Level parseVerbosityLevel() {
}

return switch (verbosity) {
case 0 -> Level.WARN;
case 1 -> Level.INFO;
case 2 -> Level.DEBUG;
case 3 -> Level.TRACE;
case 0 -> Level.INFO;
case 1 -> Level.DEBUG;
case 2 -> Level.TRACE;
default -> Level.ALL;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,21 @@ public static class RunConfiguration {

protected List<String> checkInput() {
List<String> errors = new LinkedList<>();

Path codeHomeParent = codeHomeDir();
// resources
if (dataSection.liricalDataDirectory == null) {
Path codeHomeParent = codeHomeDir();
LOGGER.debug("Data directory is unset, searching in the code home directory at: {}", codeHomeParent);
LOGGER.debug("Data directory is unset, searching next to the LIRICAL file");
Path codeHomeDataDir = codeHomeParent.resolve("data");
if (Files.isDirectory(codeHomeDataDir)) {
LOGGER.debug("Found data folder at: {}", codeHomeDataDir.toAbsolutePath());
dataSection.liricalDataDirectory = codeHomeDataDir;
} else {
String msg = "Path to Lirical data directory must be provided via `-d | --data` option";
String msg = "Path to LIRICAL data directory must be provided via `-d | --data` option";
LOGGER.error(msg);
errors.add(msg);
}
}
LOGGER.info("Using data folder at {}", dataSection.liricalDataDirectory.toAbsolutePath());

// Obsolete options must/should not be used
if (dataSection.exomiserDatabase != null) {
Expand Down Expand Up @@ -250,7 +251,7 @@ protected AnalysisOptions prepareAnalysisOptions(Lirical lirical, GenomeBuild ge

List<TermId> diseaseIds = lirical.phenotypeService().diseases().stream()
.map(Identified::id)
.filter(diseaseId -> Collections.binarySearch(diseaseDatabasePrefixes, diseaseId.getPrefix()) > 0)
.filter(diseaseId -> diseaseDatabasePrefixes.contains(diseaseId.getPrefix()))
.toList();
PretestDiseaseProbability pretestDiseaseProbability = PretestDiseaseProbabilities.uniform(diseaseIds);
builder.pretestProbability(pretestDiseaseProbability);
Expand Down Expand Up @@ -335,7 +336,7 @@ else if (elapsedTime>59) {

private static Path codeHomeDir() {
String codePath = LiricalConfigurationCommand.class.getProtectionDomain().getCodeSource().getLocation().getFile();
LOGGER.debug("Found code path at {}", codePath);
LOGGER.info("Running LIRICAL from {}", codePath);
return Path.of(codePath).toAbsolutePath().getParent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class PhenopacketCommand extends AbstractPrioritizeCommand {
public Path phenopacketPath;

@CommandLine.Option(names = {"--vcf"},
description = "Path to VCF file. This path has priority over any VCF files described in phenopacket.")
description = "Path to a VCF file. This path has priority over any VCF files described in phenopacket.")
public Path vcfPath;

@Override
Expand All @@ -59,23 +59,23 @@ protected String getGenomeBuild() {
protected AnalysisData prepareAnalysisData(Lirical lirical,
GenomeBuild genomeBuild,
TranscriptDatabase transcriptDb) throws LiricalParseException {
LOGGER.info("Reading phenopacket from {}.", phenopacketPath.toAbsolutePath());
LOGGER.info("Reading phenopacket from {}", phenopacketPath.toAbsolutePath());

PhenopacketData data = null;
try (InputStream is = new BufferedInputStream(new FileInputStream(phenopacketPath.toFile()))) {
PhenopacketImporter v2 = PhenopacketImporters.v2();
data = v2.read(is);
LOGGER.info("Success!");
} catch (PhenopacketImportException | IOException e) {
LOGGER.info("Unable to parse as v2 phenopacket, trying v1.");
LOGGER.info("Unable to parse as v2 phenopacket, trying v1");
}

if (data == null) {
try (InputStream is = new BufferedInputStream(new FileInputStream(phenopacketPath.toFile()))) {
PhenopacketImporter v1 = PhenopacketImporters.v1();
data = v1.read(is);
} catch (PhenopacketImportException | IOException e) {
LOGGER.info("Unable to parser as v1 phenopacket.");
LOGGER.info("Unable to parse as v1 phenopacket");
throw new LiricalParseException("Unable to parse phenopacket from " + phenopacketPath.toAbsolutePath());
}
}
Expand Down
11 changes: 11 additions & 0 deletions lirical-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
<dependency>
<groupId>de.charite.compbio</groupId>
<artifactId>jannovar-core</artifactId>
<exclusions>
<!-- We do not use parts of Jannovar that use the following libs: -->
<exclusion>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
</exclusion>
<exclusion>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public Builder addDiseaseDatabases(DiseaseDatabase... diseaseDatabases) {

public Builder addDiseaseDatabases(Collection<DiseaseDatabase> diseaseDatabases) {
if (diseaseDatabases == null) {
LOGGER.warn("Disease databases should not be `null`!");
LOGGER.warn("Disease databases must not be `null`!");
return this;
}
this.diseaseDatabases.addAll(diseaseDatabases);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public AnalysisResults run(AnalysisData data, AnalysisOptions options) throws Li
ProgressReporter progressReporter = new ProgressReporter(1_000, "diseases");
Stream<TestResult> testResultStream = phenotypeService.diseases().hpoDiseases()
.parallel() // why not?
.filter(d -> diseaseDatabasePrefixes.contains(d.id().getPrefix()))
.filter(disease -> diseaseDatabasePrefixes.contains(disease.id().getPrefix()))
.peek(d -> progressReporter.log())
.map(disease -> analyzeDisease(genotypeLikelihoodRatio.get(), disease, data, options, diseaseToGenotype))
.flatMap(Optional::stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@
itself. The
results of LIRICAL should not be construed as medical advice and should always be reviewed by medical
professionals.</p>
<p>See LIRICAL's <a href="https://lirical.readthedocs.io/en/latest/" target="_blank">online
<p>See LIRICAL's <a href="https://thejacksonlaboratory.github.io/LIRICAL/stable" target="_blank">online
documentation</a>.</p>

<h4><i>This LIRICAL run had the following configuration:</i></h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static LiricalDataResolver of(Path dataDirectory) throws LiricalDataExcep

private LiricalDataResolver(Path dataDirectory) throws LiricalDataException {
this.dataDirectory = Objects.requireNonNull(dataDirectory, "Data directory must not be null!");
LOGGER.debug("Using Lirical directory at `{}`.", dataDirectory.toAbsolutePath());
checkV1Resources();
}

Expand Down

0 comments on commit bfcfef7

Please sign in to comment.