Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kpmp 4434 rp expression #99

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/main/java/org/kpmp/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import org.kpmp.dataSummary.AtlasRepoSummaryResult;
import org.kpmp.dataSummary.DataSummaryService;
import org.kpmp.dataSummary.DataTypeSummary;
import org.kpmp.geneExpression.RTExpressionByTissueType;
import org.kpmp.geneExpression.RTExpressionData;
import org.kpmp.geneExpression.RTExpressionDataService;
import org.kpmp.geneExpression.*;
import org.kpmp.geneExpressionSummary.GeneExpressionSummary;
import org.kpmp.geneExpressionSummary.GeneExpressionSummaryService;
import org.kpmp.participant.ParticipantDataTypeSummary;
Expand Down Expand Up @@ -43,14 +41,17 @@ public class Query implements GraphQLQueryResolver {
private UmapDataService umapService;
private ClusterHierarchyService clusterHierarchyService;
private RTExpressionDataService rtExpressionDataService;

private RPExpressionDataService rpExpressionDataService;
private ParticipantService participantService;
private Logger logger = LoggerFactory.getLogger(Query.class);

@Autowired
public Query(AutocompleteService autocompleteService, CellTypeService cellTypeService,
UmapDataService umapService, GeneExpressionSummaryService geneExpressionSummaryService,
DataSummaryService dataSummaryService, ClusterHierarchyService clusterHierarchyService,
RTExpressionDataService rtExpressionDataService, ParticipantService participantService) {
RTExpressionDataService rtExpressionDataService, RPExpressionDataService rpExpressionDataService,
ParticipantService participantService) {

this.autocompleteService = autocompleteService;
this.cellTypeService = cellTypeService;
Expand All @@ -59,6 +60,7 @@ public Query(AutocompleteService autocompleteService, CellTypeService cellTypeSe
this.dataSummaryService = dataSummaryService;
this.clusterHierarchyService = clusterHierarchyService;
this.rtExpressionDataService = rtExpressionDataService;
this.rpExpressionDataService = rpExpressionDataService;
this.participantService = participantService;
}

Expand Down Expand Up @@ -142,6 +144,16 @@ public List<? extends RTExpressionData> getRTGeneExpressionByStructure(String st
}
}

public RPExpressionByTissueType getRPGeneExpressionByTissue(String geneSymbol)
throws Exception {
try {
return rpExpressionDataService.getByGeneSymbolPerTissue(geneSymbol);
} catch (Exception e) {
logger.error(e.getMessage());
throw e;
}
}

public ParticipantDataTypeSummary getDataTypeInformationByParticipant(String redcapId) {
return participantService.getExperimentCounts(redcapId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.kpmp.geneExpression;

import java.util.List;

public class RPExpressionByTissueType {

private List<? extends RPExpressionData> all;
private List<? extends RPExpressionData> aki;
private List<? extends RPExpressionData> ckd;
private List<? extends RPExpressionData> hrt;
private List<? extends RPExpressionData> dmr;

public List<? extends RPExpressionData> getAll() {
return all;
}

public void setAll(List<? extends RPExpressionData> all) {
this.all = all;
}

public List<? extends RPExpressionData> getAki() {
return aki;
}

public void setAki(List<? extends RPExpressionData> aki) {
this.aki = aki;
}

public List<? extends RPExpressionData> getCkd() {
return ckd;
}

public void setCkd(List<? extends RPExpressionData> ckd) {
this.ckd = ckd;
}

public List<? extends RPExpressionData> getHrt() {
return hrt;
}

public void setHrt(List<? extends RPExpressionData> hrt) {
this.hrt = hrt;
}

public List<? extends RPExpressionData> getDmr() {
return dmr;
}

public void setDmr(List<? extends RPExpressionData> dmr) {
this.dmr = dmr;
}
}

11 changes: 10 additions & 1 deletion src/main/java/org/kpmp/geneExpression/RPExpressionData.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class RPExpressionData {
@Column(name = "adj_p_val")
private Double adjPVal;

@Column(name = "fold_chane")
@Column(name = "fold_change")
private Double foldChange;

@Column(name = "tissue_type")
Expand All @@ -49,6 +49,8 @@ public class RPExpressionData {
@Column(name = "region")
private String region;

@Column(name = "sample_count")
private Integer sampleCount;
public Integer getId() {
return id;
}
Expand Down Expand Up @@ -153,4 +155,11 @@ public void setRegion(String region) {
this.region = region;
}

public Integer getSampleCount() {
return sampleCount;
}

public void setSampleCount(Integer sampleCount) {
this.sampleCount = sampleCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface RPExpressionDataRepository extends CrudRepository<RPExpressionData, Integer> {


@Query(value = "SELECT rpe.*, count(*) as sample_count FROM rp_expression rpe " +
"JOIN rp_metadata rpm ON LOWER(rpe.region) = LOWER(rpm.tissue_region) " +
"WHERE rpe.gene_symbol = :geneSymbol AND rpe.tissue_type = :tissueType " +
"GROUP BY rpe.region", nativeQuery = true)
List<RPExpressionData> findByGeneSymbolAndTissueTypeWithCounts(String geneSymbol, String tissueType);
@Cacheable("rpExpCountByGene")
@Query(value = "SELECT COUNT(*) FROM rp_expression WHERE gene_symbol = :gene", nativeQuery = true)
long getCountByGene(@Param("gene") String gene);
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.kpmp.geneExpression;

import org.kpmp.TissueTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RPExpressionDataService {

RPExpressionDataRepository rpExpressionDataRepository;

@Autowired
public RPExpressionDataService(RPExpressionDataRepository rpExpressionDataRepository) {
this.rpExpressionDataRepository = rpExpressionDataRepository;
}

public RPExpressionByTissueType getByGeneSymbolPerTissue(String geneSymbol) {
RPExpressionByTissueType rpExpressionByTissueType = new RPExpressionByTissueType();

rpExpressionByTissueType.setAki(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.AKI.getParticipantTissueType()));
rpExpressionByTissueType.setCkd(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.CKD.getParticipantTissueType()));
rpExpressionByTissueType.setDmr(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.DMR.getParticipantTissueType()));
rpExpressionByTissueType.setHrt(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()));
rpExpressionByTissueType.setAll(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.ALL.getParticipantTissueType()));

return rpExpressionByTissueType;

}
}
27 changes: 27 additions & 0 deletions src/main/resources/knowledge_environment.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Query {
dataTypesForConcept(geneSymbol: String, clusterName: String): [String]
getDataTypeSummaryInformation: [DataTypeSummaryInformation]
getRTGeneExpressionByTissue(comparisonType: String, geneSymbol: String): RTGeneExpressionByTissue
getRPGeneExpressionByTissue(geneSymbol: String): RPGeneExpressionByTissue
getRTGeneExpressionByStructure(structure: String): [RTGeneExpression]
getSummaryData: [DataTypeSummaryInformation]
getDataTypeInformationByParticipant(redcapId: String!): ParticipantDataTypeSummary
Expand Down Expand Up @@ -74,6 +75,7 @@ type DataTypeSummaryInformation {
participantCount: Long
}


type AutoCompleteResult {
value: String
name: String
Expand Down Expand Up @@ -170,6 +172,31 @@ type RTGeneExpressionByTissue {
aki: [RTGeneExpression]
}

type RPGeneExpression {
id: ID
geneSymbol: String
fdrConfidence: String
accession: String
description: String
coveragePct: Int
numPeptides: Int
numUniquePeptides: Int
comparison: String
region: String
foldChange: Float
adjPVal: Float
tissueType: String
sampleCount: Int
}

type RPGeneExpressionByTissue {
all: [RPGeneExpression]
hrt: [RPGeneExpression]
ckd: [RPGeneExpression]
dmr: [RPGeneExpression]
aki: [RPGeneExpression]
}

type ParticipantSummaryDataset {
participantId: String
redcapId: String
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/org/kpmp/QueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.kpmp.dataSummary.AtlasRepoSummaryResult;
import org.kpmp.dataSummary.DataSummaryService;
import org.kpmp.dataSummary.DataTypeSummary;
import org.kpmp.geneExpression.RPExpressionDataService;
import org.kpmp.geneExpression.RTExpressionByTissueType;
import org.kpmp.geneExpression.RTExpressionDataAllSegments;
import org.kpmp.geneExpression.RTExpressionDataService;
Expand Down Expand Up @@ -64,11 +65,14 @@ public class QueryTest {
@Mock
private ParticipantTissueTypeSummary participantTissueTypeSummary;

@Mock
private RPExpressionDataService rpExpressionDataService;

@Before
public void setUp() throws Exception {
MockitoAnnotations.openMocks(this);
query = new Query(autocompleteService, cellTypeService, umapDataService, geneExpressionService,
dataSummaryService, clusterHierarchyService, rtExpressionDataService, participantService);
dataSummaryService, clusterHierarchyService, rtExpressionDataService, rpExpressionDataService, participantService);
}

@After
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.kpmp.geneExpression;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class RPExpressionDataByTissueTypeTest {

private RPExpressionByTissueType rpExpressionByTissueType;

@Before
public void setUp() throws Exception {
rpExpressionByTissueType = new RPExpressionByTissueType();
}

@After
public void tearDown() throws Exception {
rpExpressionByTissueType = null;
}

@Test
public void setAll() {
RPExpressionData allData = new RPExpressionData();
List<? extends RPExpressionData> allataList = Arrays.asList(allData);
rpExpressionByTissueType.setAll(allataList);
List<? extends RPExpressionData> actual = rpExpressionByTissueType.getAll();
assertEquals(allataList, actual);
}

@Test
public void setAki() {
RPExpressionData allAkiData = new RPExpressionData();
List<? extends RPExpressionData> allAkiDataList = Arrays.asList(allAkiData);
rpExpressionByTissueType.setAki(allAkiDataList);
List<? extends RPExpressionData> actual = rpExpressionByTissueType.getAki();
assertEquals(allAkiDataList, actual);
}

@Test
public void setCkd() {
RPExpressionData allCkdData = new RPExpressionData();
List<? extends RPExpressionData> allCkdDataList = Arrays.asList(allCkdData);
rpExpressionByTissueType.setCkd(allCkdDataList);
List<? extends RPExpressionData> actual = rpExpressionByTissueType.getCkd();
assertEquals(allCkdDataList, actual);
}

@Test
public void setHrt() {
RPExpressionData allHrtData = new RPExpressionData();
List<? extends RPExpressionData> allHrtDataList = Arrays.asList(allHrtData);
rpExpressionByTissueType.setHrt(allHrtDataList);
List<? extends RPExpressionData> actual = rpExpressionByTissueType.getHrt();
assertEquals(allHrtDataList, actual);
}

@Test
public void setDmr() {
RPExpressionData allDmrData = new RPExpressionData();
List<? extends RPExpressionData> allDmrDataList = Arrays.asList(allDmrData);
rpExpressionByTissueType.setDmr(allDmrDataList);
List<? extends RPExpressionData> actual = rpExpressionByTissueType.getDmr();
assertEquals(allDmrDataList, actual);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.kpmp.geneExpression;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.kpmp.TissueTypeEnum;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.Arrays;
import java.util.List;

import static org.mockito.Mockito.when;

public class RPExpressionDataServiceTest {

@Mock
RPExpressionDataRepository rpExpressionDataRepository;

RPExpressionDataService rpExpressionDataService;

@Before
public void setUp() throws Exception {
MockitoAnnotations.openMocks(this);
rpExpressionDataService = new RPExpressionDataService(rpExpressionDataRepository);
}

@After
public void tearDown() throws Exception {
MockitoAnnotations.openMocks(this).close();
rpExpressionDataService = null;
}

@Test
public void testGetByGeneSymbolPerTissue() throws Exception {
List<RPExpressionData> rpExpressionDataAki = Arrays.asList(new RPExpressionData[]{new RPExpressionData()});
List<RPExpressionData> rpExpressionDataCkd = Arrays.asList(new RPExpressionData[]{new RPExpressionData()});
List<RPExpressionData> rpExpressionDataHrt = Arrays.asList(new RPExpressionData[]{new RPExpressionData()});
List<RPExpressionData> rpExpressionDataDmr = Arrays.asList(new RPExpressionData[]{new RPExpressionData()});
List<RPExpressionData> rpExpressionDataAll = Arrays.asList(new RPExpressionData[]{new RPExpressionData()});

when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType())).
thenReturn(rpExpressionDataAki);
when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.CKD.getParticipantTissueType())).
thenReturn(rpExpressionDataCkd);
when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType())).
thenReturn(rpExpressionDataHrt);
when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType())).
thenReturn(rpExpressionDataDmr);
when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.ALL.getParticipantTissueType())).
thenReturn(rpExpressionDataAll);

RPExpressionByTissueType rpExpressionByTissueType = rpExpressionDataService.getByGeneSymbolPerTissue("gene");

assertEquals(rpExpressionByTissueType.getAki(), rpExpressionDataAki);
assertEquals(rpExpressionByTissueType.getHrt(), rpExpressionDataHrt);
assertEquals(rpExpressionByTissueType.getCkd(), rpExpressionDataCkd);
assertEquals(rpExpressionByTissueType.getAll(), rpExpressionDataAll);
assertEquals(rpExpressionByTissueType.getDmr(), rpExpressionDataDmr);

}
}
Loading