use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters in project EnrichmentMapApp by BaderLab.
the class LegacySessionLoader method loadSession.
/**
* Restore Enrichment maps
*
* @param pStateFileList - list of files associated with thie session
*/
@SuppressWarnings("unchecked")
public void loadSession(CySession session) {
Map<Long, EnrichmentMapParameters> paramsMap = new HashMap<>();
Map<Long, EnrichmentMap> enrichmentMapMap = new HashMap<>();
List<File> fileList = session.getAppFileListMap().get(CyActivator.APP_NAME);
try {
//go through the prop files first to create the correct objects to be able to add other files to.
for (File prop_file : fileList) {
if (prop_file.getName().contains(".props")) {
InputStream reader = streamUtil.getInputStream(prop_file.getAbsolutePath());
String fullText = new Scanner(reader, "UTF-8").useDelimiter("\\A").next();
//Given the file with all the parameters create a new parameter
EnrichmentMapParameters params = enrichmentMapParametersFactory.create(fullText);
EnrichmentMap em = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
//get the network name
String param_name = em.getName();
//TODO:distinguish between GSEA and EM saved sessions
String props_name = (prop_file.getName().split("\\."))[0];
String networkName = param_name;
//related to bug ticket #49
if (!props_name.equalsIgnoreCase(param_name))
networkName = props_name;
//after associated the properties with the network
//initialized each Dataset that we have files for
HashMap<String, DataSetFiles> files = params.getFiles();
for (Iterator<String> j = params.getFiles().keySet().iterator(); j.hasNext(); ) {
String current_dataset = j.next();
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
em.createDataSet(current_dataset, method, files.get(current_dataset));
}
CyNetwork network = getNetworkByName(networkName);
Long suid = network.getSUID();
em.setNetworkID(suid);
paramsMap.put(suid, params);
enrichmentMapMap.put(suid, em);
}
}
// go through the rest of the files
for (File propFile : fileList) {
FileNameParts parts = ParseFileName(propFile);
if (parts == null || propFile.getName().contains(".props"))
continue;
CyNetwork net = getNetworkByName(parts.name);
EnrichmentMap em = net == null ? null : enrichmentMapMap.get(net.getSUID());
EnrichmentMapParameters params = paramsMap.get(net.getSUID());
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
if (em == null) {
System.out.println("network for file" + propFile.getName() + " does not exist.");
} else if ((!propFile.getName().contains(".props")) && (!propFile.getName().contains(".expression1.txt")) && (!propFile.getName().contains(".expression2.txt"))) {
HashMap<String, String> props = params.getProps();
//if this a dataset specific file make sure there is a dataset object for it
if (!(parts.dataset == null) && em.getDataSet(parts.dataset) == null && !parts.dataset.equalsIgnoreCase("signature"))
em.createDataSet(parts.dataset, method, params.getFiles().get(parts.dataset));
if (parts.type == null)
System.out.println("Sorry, unable to determine the type of the file: " + propFile.getName());
//read the file
InputStream reader = streamUtil.getInputStream(propFile.getAbsolutePath());
String fullText = new Scanner(reader, "UTF-8").useDelimiter("\\A").next();
//if the file is empty then skip it
if (fullText == null || fullText.equalsIgnoreCase(""))
continue;
if (propFile.getName().contains(".gmt")) {
HashMap<String, GeneSet> gsMap = (HashMap<String, GeneSet>) params.repopulateHashmap(fullText, 1);
if (propFile.getName().contains(".signature.gmt")) {
// TODO Find a better way to serialize EMSignatureDataSet
String sdsName = propFile.getName().replace(".signature.gmt", "");
sdsName = NamingUtil.getUniqueName(sdsName, em.getSignatureDataSets().keySet());
EMSignatureDataSet sigDataSet = new EMSignatureDataSet(sdsName);
em.addSignatureDataSet(sigDataSet);
SetOfGeneSets sigGeneSets = sigDataSet.getGeneSetsOfInterest();
gsMap.forEach((k, v) -> sigGeneSets.addGeneSet(k, v));
} else if (propFile.getName().contains(".set2.gmt")) {
// account for legacy session files
if (em.getAllGeneSets().containsKey(LegacySupport.DATASET2)) {
SetOfGeneSets gs = new SetOfGeneSets(LegacySupport.DATASET2, props);
gs.setGeneSets(gsMap);
}
} else {
SetOfGeneSets gs = new SetOfGeneSets(parts.dataset, props);
gs.setGeneSets(gsMap);
em.getDataSets().get(parts.dataset).setSetOfGeneSets(gs);
}
}
if (propFile.getName().contains(".genes.txt")) {
HashMap<String, Integer> genes = params.repopulateHashmap(fullText, 2);
genes.forEach(em::addGene);
//ticket #188 - unable to open session files that have empty enrichment maps.
if (genes != null && !genes.isEmpty())
// Ticket #107 : restore also gene count (needed to determine the next free hash in case we do PostAnalysis with a restored session)
em.setNumberOfGenes(Math.max(em.getNumberOfGenes(), Collections.max(genes.values()) + 1));
}
if (propFile.getName().contains(".hashkey2genes.txt")) {
HashMap<Integer, String> hashkey2gene = params.repopulateHashmap(fullText, 5);
//ticket #188 - unable to open session files that have empty enrichment maps.
if (hashkey2gene != null && !hashkey2gene.isEmpty())
// Ticket #107 : restore also gene count (needed to determine the next free hash in case we do PostAnalysis with a restored session)
em.setNumberOfGenes(Math.max(em.getNumberOfGenes(), Collections.max(hashkey2gene.keySet()) + 1));
}
if ((parts.type != null && (parts.type.equalsIgnoreCase("ENR") || (parts.type.equalsIgnoreCase("SubENR")))) || propFile.getName().contains(".ENR1.txt") || propFile.getName().contains(".SubENR1.txt")) {
SetOfEnrichmentResults enrichments;
int temp = 1;
//check to see if this dataset has enrichment results already
if (parts.dataset != null && em.getDataSet(parts.dataset).getEnrichments() != null) {
enrichments = em.getDataSet(parts.dataset).getEnrichments();
} else if (parts.dataset == null) {
enrichments = em.getDataSet(LegacySupport.DATASET1).getEnrichments();
/*enrichments = new SetOfEnrichmentResults(EnrichmentMap.DATASET1,props);
em.getDataset(EnrichmentMap.DATASET1).setEnrichments(enrichments);*/
} else {
enrichments = new SetOfEnrichmentResults(parts.dataset, props);
em.getDataSet(parts.dataset).setEnrichments(enrichments);
}
if (parts.type.equalsIgnoreCase("ENR") || propFile.getName().contains(".ENR1.txt")) {
if (params.getMethod().equalsIgnoreCase(EnrichmentMapParameters.method_GSEA))
enrichments.setEnrichments(params.repopulateHashmap(fullText, 3));
else
enrichments.setEnrichments(params.repopulateHashmap(fullText, 4));
}
}
//it would only happen for sessions saved with version 0.8
if (propFile.getName().contains(".RANKS1.txt") || propFile.getName().contains(".RANKS1Genes.txt")) {
Ranking new_ranking;
//Check to see if there is already GSEARanking
if (em.getDataSet(LegacySupport.DATASET1).getExpressionSets().getAllRanksNames().contains(Ranking.GSEARanking)) {
new_ranking = em.getDataSet(LegacySupport.DATASET1).getExpressionSets().getRanksByName(Ranking.GSEARanking);
} else {
new_ranking = new Ranking();
em.getDataSet(LegacySupport.DATASET1).getExpressionSets().addRanks(Ranking.GSEARanking, new_ranking);
}
if (propFile.getName().contains(".RANKS1.txt")) {
Map<Integer, Rank> ranks = (Map<Integer, Rank>) params.repopulateHashmap(fullText, 7);
ranks.forEach(new_ranking::addRank);
}
// if(prop_file.getName().contains(".RANKS1Genes.txt"))
// new_ranking.setRank2gene(em.getParams().repopulateHashmap(fullText,7));
// if(prop_file.getName().contains(".RANKS1.txt"))
// new_ranking.setRanking(em.getParams().repopulateHashmap(fullText,6));
}
if (propFile.getName().contains(".RANKS.txt")) {
if (parts.ranks_name == null) {
//we need to get the name of this set of rankings
// network_name.ranking_name.ranks.txt --> split by "." and get 2
String[] file_name_tokens = (propFile.getName()).split("\\.");
if ((file_name_tokens.length == 4) && (file_name_tokens[1].equals("Dataset 1 Ranking") || file_name_tokens[1].equals("Dataset 2 Ranking")) || (propFile.getName().contains(Ranking.GSEARanking)))
parts.ranks_name = Ranking.GSEARanking;
else //this is an extra rank file for backwards compatability. Ignore it.
if ((file_name_tokens.length == 4) && (file_name_tokens[1].equals("Dataset 1") || file_name_tokens[1].equals("Dataset 2")) && file_name_tokens[2].equals("RANKS"))
continue;
else
//file name is not structured properly --> default to file name
parts.ranks_name = propFile.getName();
}
Ranking new_ranking = new Ranking();
Map<Integer, Rank> ranks = (Map<Integer, Rank>) params.repopulateHashmap(fullText, 6);
ranks.forEach(new_ranking::addRank);
if (parts.dataset != null)
em.getDataSet(parts.dataset).getExpressionSets().addRanks(parts.ranks_name, new_ranking);
else
em.getDataSet(LegacySupport.DATASET1).getExpressionSets().addRanks(parts.ranks_name, new_ranking);
}
//Deal with legacy issues
if (params.isTwoDatasets()) {
//make sure there is a Dataset2
if (!em.getDataSets().containsKey(LegacySupport.DATASET2))
em.createDataSet(LegacySupport.DATASET2, method, new DataSetFiles());
if (propFile.getName().contains(".ENR2.txt") || propFile.getName().contains(".SubENR2.txt")) {
SetOfEnrichmentResults enrichments;
//check to see if this dataset has enrichment results already
if (em.getDataSet(LegacySupport.DATASET2).getEnrichments() != null) {
enrichments = em.getDataSet(LegacySupport.DATASET2).getEnrichments();
} else {
enrichments = new SetOfEnrichmentResults(LegacySupport.DATASET2, props);
em.getDataSet(LegacySupport.DATASET2).setEnrichments(enrichments);
}
if (propFile.getName().contains(".ENR2.txt")) {
if (params.getMethod().equalsIgnoreCase(EnrichmentMapParameters.method_GSEA))
enrichments.setEnrichments(params.repopulateHashmap(fullText, 3));
else
enrichments.setEnrichments(params.repopulateHashmap(fullText, 4));
}
}
//it would only happen for sessions saved with version 0.8
if (propFile.getName().contains(".RANKS2.txt") || propFile.getName().contains(".RANKS2Genes.txt")) {
Ranking new_ranking;
// Check to see if there is already GSEARanking
if (em.getDataSet(LegacySupport.DATASET2).getExpressionSets().getAllRanksNames().contains(Ranking.GSEARanking)) {
new_ranking = em.getDataSet(LegacySupport.DATASET2).getExpressionSets().getRanksByName(Ranking.GSEARanking);
} else {
new_ranking = new Ranking();
em.getDataSet(LegacySupport.DATASET2).getExpressionSets().addRanks(Ranking.GSEARanking, new_ranking);
}
if (propFile.getName().contains(".RANKS2.txt")) {
Map<Integer, Rank> ranks = (Map<Integer, Rank>) params.repopulateHashmap(fullText, 6);
ranks.forEach(new_ranking::addRank);
}
}
}
}
}
//info from the parameters
for (int i = 0; i < fileList.size(); i++) {
File prop_file = fileList.get(i);
FileNameParts parts_exp = ParseFileName(prop_file);
//unrecognized file
if ((parts_exp == null) || (parts_exp.name == null))
continue;
CyNetwork net = getNetworkByName(parts_exp.name);
EnrichmentMap map = net == null ? null : enrichmentMapMap.get(net.getSUID());
EnrichmentMapParameters params = paramsMap.get(net.getSUID());
Map<String, String> props = params.getProps();
if (parts_exp.type != null && parts_exp.type.equalsIgnoreCase("expression")) {
if (map.getDataSets().containsKey(parts_exp.dataset)) {
EMDataSet ds = map.getDataSet(parts_exp.dataset);
ds.getDataSetFiles().setExpressionFileName(prop_file.getAbsolutePath());
ds.getExpressionSets().setFilename(prop_file.getAbsolutePath());
ExpressionFileReaderTask expressionFile1 = new ExpressionFileReaderTask(ds);
GeneExpressionMatrix matrix = expressionFile1.parse();
matrix.restoreProps(parts_exp.dataset, props);
}
}
//Deal with legacy session files.
if (prop_file.getName().contains("expression1.txt")) {
EMDataSet ds1 = map.getDataSet(LegacySupport.DATASET1);
ds1.getDataSetFiles().setExpressionFileName(prop_file.getAbsolutePath());
ds1.getExpressionSets().setFilename(prop_file.getAbsolutePath());
ExpressionFileReaderTask expressionFile1 = new ExpressionFileReaderTask(ds1);
expressionFile1.parse();
}
if (prop_file.getName().contains("expression2.txt")) {
EMDataSet ds2 = map.getDataSet(LegacySupport.DATASET2);
ds2.getDataSetFiles().setExpressionFileName(prop_file.getAbsolutePath());
ds2.getExpressionSets().setFilename(prop_file.getAbsolutePath());
ExpressionFileReaderTask expressionFile2 = new ExpressionFileReaderTask(ds2);
expressionFile2.parse();
//are dealing with two distinct expression files.
if (map.getDataSet(LegacySupport.DATASET2) != null && map.getDataSet(LegacySupport.DATASET2).getGeneSetsOfInterest() != null && !map.getDataSet(LegacySupport.DATASET2).getGeneSetsOfInterest().getGeneSets().isEmpty()) {
map.setDistinctExpressionSets(true);
map.getDataSet(LegacySupport.DATASET1).setDataSetGenes(new HashSet<Integer>((Set<Integer>) map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getGeneIds()));
map.getDataSet(LegacySupport.DATASET2).setDataSetGenes(new HashSet<Integer>((Set<Integer>) map.getDataSet(LegacySupport.DATASET2).getExpressionSets().getGeneIds()));
}
}
}
//iterate over the networks
for (Iterator<Long> j = enrichmentMapMap.keySet().iterator(); j.hasNext(); ) {
Long id = j.next();
EnrichmentMap map = enrichmentMapMap.get(id);
//only initialize objects if there is a map for this network
if (map != null) {
if (map.getDataSets().size() > 1) {
Set<Integer> dataset1_genes = map.getDataSets().get(LegacySupport.DATASET1).getDataSetGenes();
Set<Integer> dataset2_genes = map.getDataSets().get(LegacySupport.DATASET2).getDataSetGenes();
if (!dataset1_genes.equals(dataset2_genes))
map.setDistinctExpressionSets(true);
}
//initialize the Genesets (makes sure the leading edge is set correctly)
//Initialize the set of genesets and GSEA results that we want to compute over
InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(map);
// MKTODO really?
genesets_init.setThrowIfMissing(false);
genesets_init.initializeSets(null);
// //for each map compute the similarity matrix, (easier than storing it) compute the geneset similarities
// ComputeSimilarityTask similarities = new ComputeSimilarityTask(map, ComputeSimilarityTask.ENRICHMENT);
// Map<String, GenesetSimilarity> similarity_results = similarities.computeGenesetSimilarities(null);
// map.setGenesetSimilarity(similarity_results);
//
// // also compute geneset similarities between Enrichment- and Signature Genesets (if any)
// if (! map.getSignatureGenesets().isEmpty()){
// ComputeSimilarityTask sigSimilarities = new ComputeSimilarityTask(map, ComputeSimilarityTask.SIGNATURE);
// Map<String, GenesetSimilarity> sig_similarity_results = sigSimilarities.computeGenesetSimilarities(null);
// map.getGenesetSimilarity().putAll(sig_similarity_results);
// }
}
//end of if(map != null)
}
for (Iterator<Long> j = enrichmentMapMap.keySet().iterator(); j.hasNext(); ) {
Long id = j.next();
CyNetwork currentNetwork = cyNetworkManager.getNetwork(id);
EnrichmentMap map = enrichmentMapMap.get(id);
map.setLegacy(true);
emManager.registerEnrichmentMap(map);
if (!j.hasNext()) {
//set the last network to be the one viewed and initialize the parameters panel
cyApplicationManager.setCurrentNetwork(currentNetwork);
}
}
} catch (Exception ee) {
ee.printStackTrace();
}
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testGenericFileReader_5columns.
@Test
public void testGenericFileReader_5columns(Provider<EnrichmentMapParameters> empFactory) throws Exception {
//load the test expression file
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/generic_enr_5col.txt";
//create a new instance of the parameters
EnrichmentMapParameters params = empFactory.get();
//set enrichment results file name
params.getFiles().get(LegacySupport.DATASET1).setEnrichmentFileName1(testDataFileName);
//Create a new Enrichment map
EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
//get the default dataset
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
// check if empty
assertEquals(0, map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments().size());
// read
ParseGenericEnrichmentResults task = new ParseGenericEnrichmentResults(dataset);
task.run(taskMonitor);
Map<String, EnrichmentResult> results = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
// check we have 4 results
assertEquals(4, results.size());
// check pValues
assertEquals(0.01, ((GenericResult) results.get("GO:0000346")).getPvalue(), 0.0);
assertEquals(0.05, ((GenericResult) results.get("GO:0030904")).getPvalue(), 0.0);
assertEquals(0.05, ((GenericResult) results.get("GO:0008623")).getPvalue(), 0.0);
assertEquals(5.60E-42, ((GenericResult) results.get("GO:0046540")).getPvalue(), 0.0);
// check getFdrqvalues
assertEquals(0.02, ((GenericResult) results.get("GO:0000346")).getFdrqvalue(), 0.0);
assertEquals(0.10, ((GenericResult) results.get("GO:0030904")).getFdrqvalue(), 0.0);
assertEquals(0.12, ((GenericResult) results.get("GO:0008623")).getFdrqvalue(), 0.0);
assertEquals(0.03, ((GenericResult) results.get("GO:0046540")).getFdrqvalue(), 0.0);
// check phenotypes
assertEquals(1.0, ((GenericResult) results.get("GO:0000346")).getNES(), 0.0);
assertEquals(1.0, ((GenericResult) results.get("GO:0030904")).getNES(), 0.0);
assertEquals(-1.0, ((GenericResult) results.get("GO:0008623")).getNES(), 0.0);
assertEquals(-1.0, ((GenericResult) results.get("GO:0046540")).getNES(), 0.0);
return;
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testGSEAEDBEnrichmentsReader.
//test GSEA enrichment results reader
@Test
public void testGSEAEDBEnrichmentsReader(Provider<EnrichmentMapParameters> empFactory) throws Exception {
//load the test enrichment files - GSEA creates two enrichment results files.
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_example_results/edb/results.edb";
//create a new instance of the parameters
EnrichmentMapParameters params = empFactory.get();
//set enrichment file name
params.getFiles().get(LegacySupport.DATASET1).setEnrichmentFileName1(testDataFileName);
//Create a new Enrichment map
EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
//get the default dataset
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
ParseEDBEnrichmentResults task = new ParseEDBEnrichmentResults(dataset);
task.run(taskMonitor);
//Get the enrichment
Map<String, EnrichmentResult> enrichments = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
assertEquals(14, enrichments.size());
//Check the contents of some of the genesets
// example from file 1 (ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612)
//check p-values
assertEquals(0.2271, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getPvalue(), 0.0);
//check fdr value
assertEquals(0.2447, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getFdrqvalue(), 0.0);
//check ES value
assertEquals(0.7852, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getES(), 0.0);
//check NES
assertEquals(1.1793, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getNES(), 0.0);
//check ranks at max
assertEquals(6, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getRankAtMax());
//check size
assertEquals(2, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getGsSize());
// example from file 2 (EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143)
//check p-values
assertEquals(0.4545, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getPvalue(), 0.0);
//check fdr value
assertEquals(0.8650, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getFdrqvalue(), 0.0);
//check ES value
assertEquals(-0.4707, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getES(), 0.0);
//check NES
assertEquals(-0.9696, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getNES(), 0.0);
//check ranks at max
//The Rank at max in the edb file is different from the excel files. In the excel file that we have been
// using up until now they convert the rank as if you are counting from the bottom of the list but in the
//edb file they count from the top of the ranked list (going from positive to negative ES scores)
assertEquals(15, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getRankAtMax());
//check size
assertEquals(39, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getGsSize());
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testExpression1ReaderRnk.
@Test
public void testExpression1ReaderRnk(Provider<EnrichmentMapParameters> empFactory) throws Exception {
//load the test expression file
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/ExpressionTestFile.rnk";
//create a new instance of the parameters
EnrichmentMapParameters params = empFactory.get();
//set expression file name
params.getFiles().get(LegacySupport.DATASET1).setExpressionFileName(testDataFileName);
//Create a new Enrichment map
EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
//get the default dataset
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
//make sure that the genes are empty
assertEquals(0, map.getNumberOfGenes());
//add the gene to the master list of genes
map.addGene("GLS");
map.addGene("PSMA1");
map.addGene("ZP1");
map.addGene("ZYX");
//make sure all four genes have been associated
assertEquals(4, map.getNumberOfGenes());
//load expression file
ExpressionFileReaderTask task = new ExpressionFileReaderTask(dataset);
task.run(taskMonitor);
//There was one more gene in the expression file that wasn't in the set of genes
//make sure it was was added
assertEquals(4, map.getNumberOfGenes());
assertEquals(4, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumGenes());
assertEquals(3, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
assertEquals(0.47536945, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 0.0);
assertEquals(0.5418719, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMaxExpression(), 0.0);
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testExpression1ReaderEDBRnk.
@Test
public void testExpression1ReaderEDBRnk(Provider<EnrichmentMapParameters> empFactory) throws Exception {
//load the test expression file
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/ExpressionTestFile_edbrnk.rnk";
//create a new instance of the parameters
EnrichmentMapParameters params = empFactory.get();
//set gmt file name
params.getFiles().get(LegacySupport.DATASET1).setExpressionFileName(testDataFileName);
//Create a new Enrichment map
EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
//get the default dataset
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
//make sure that the genes are empty
assertEquals(0, map.getNumberOfGenes());
//add the gene to the master list of genes
map.addGene("GLS");
map.addGene("PSMA1");
map.addGene("ZP1");
map.addGene("ZYX");
//make sure all four genes have been associated
assertEquals(4, map.getNumberOfGenes());
//load expression file
ExpressionFileReaderTask task = new ExpressionFileReaderTask(dataset);
task.run(taskMonitor);
//There was one more gene in the expression file that wasn't in the set of genes
//make sure it was was added
assertEquals(4, map.getNumberOfGenes());
assertEquals(4, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumGenes());
assertEquals(3, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
assertEquals(0.47536945, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 0.0);
assertEquals(0.5418719, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMaxExpression(), 0.0);
}
Aggregations