-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from Jean-Baptiste-Camps/dev
Version 0.3.0
- Loading branch information
Showing
73 changed files
with
3,316 additions
and
1,189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
\.Rhistory | ||
\.gitignore | ||
\.git | ||
version_history | ||
deprec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
.Rhistory | ||
inst/doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
exportPattern("^[[:alpha:]]+") | ||
importFrom("graphics", "axis", "barplot", "legend", "par", "plot","title") | ||
exportPattern("^[^\\.]") # This exports everything from stemmatology | ||
# namespace that does not start with a dot. If at some point we | ||
# want a more explicit listing, we might use export(PCC, PCC.Exploratory…) | ||
importFrom("graphics", "axis", "barplot", "plot","title") | ||
# It would be possible to remove stats import with a few modifications (only 2 uses) | ||
importFrom("stats", "fisher.test", "na.omit") | ||
importFrom("utils", "read.csv") | ||
importFrom("sna", "gplot", "gplot.layout.fruchtermanreingold") | ||
importFrom("network", "as.network", "network.vertex.names", "as.matrix.network", "set.vertex.attribute", "get.vertex.attribute") | ||
importFrom("cluster", "pam") | ||
importFrom("igraph", "graph_from_edgelist", "layout_as_tree", "plot.igraph", "E", "union", "topo_sort","V","neighbors") | ||
importFrom("igraph", "graph_from_edgelist", "layout_as_tree", "layout_with_fr", "plot.igraph", "E", "union", "topo_sort","V","neighbors", "as_adjacency_matrix") | ||
importFrom("xml2", "read_xml", "xml_ns_strip", "xml_find_all", "xml_text") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,149 @@ | ||
PCC.Exploratory <- | ||
function(x, omissionsAsReadings = FALSE, alternateReadings = FALSE, pauseAtPlot = FALSE, | ||
interactive = TRUE) { | ||
# TODO(JBC): dans ce groupe de fonction, comme dans le précédent, il est | ||
# impératif de tester que les options font bien leur job (y compris en | ||
# étant passées aux sous-fonctions) This is the global function for | ||
# exploratory methods of the PCC type. In entry, a matrix with a column | ||
# per witness, and a row per variant location, with readings coded | ||
# with numbers. TODO(JBC): une version prenant en compte interactive = | ||
# FALSE, pour tout faire d'elle-même avec des valeurs moyennes (pas pour | ||
function(x, | ||
omissionsAsReadings = FALSE, | ||
alternateReadings = FALSE, | ||
pauseAtPlot = FALSE, | ||
ask = TRUE, | ||
threshold = NULL, | ||
verbose = FALSE | ||
) { | ||
# This is the global function for exploratory methods of the PCC type. | ||
# In entry, a matrix with a column per witness, and a row per variant location, | ||
# with readings coded with numbers. | ||
# TODO(JBC): une version prenant en compte ask = FALSE, | ||
# pour tout faire d'elle-même avec des valeurs moyennes (pas pour | ||
# tout de suite) - ou demander à l'utilisateur de les choisir plutôt | ||
# que de proposer des valeurs par défaut risquées | ||
if (!is.matrix(x)) { | ||
stop("Input must be a matrix.") | ||
stop("Input must be a matrix.") | ||
} | ||
if (ask == FALSE & is.null(threshold)){ | ||
stop("you must specify threshold with ask = FALSE") | ||
} | ||
tableVariantes = x | ||
pccConflicts = PCC.conflicts(tableVariantes, omissionsAsReadings = omissionsAsReadings, alternateReadings = alternateReadings) # Simple interaction, which tests for value inputed by the user | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
pccConflicts = PCC.conflicts(tableVariantes, | ||
omissionsAsReadings = omissionsAsReadings, | ||
alternateReadings = alternateReadings) | ||
# If there are no conflicts, output directly | ||
if (sum(pccConflicts$conflictsTotal[, 1]) == 0) { | ||
return(pccConflicts) | ||
} | ||
# Simple interaction, which tests for value inputed by the user | ||
if(ask == TRUE){ | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
answerOne = readline("Do you want to proceed to the analysis of the network conflictuality ? Y/N \n ") | ||
if (answerOne != "N" && answerOne != "Y") { | ||
print("Please enter Y (yes) or N (no).") | ||
print("Please enter Y (yes) or N (no).") | ||
} | ||
if (answerOne == "N") { | ||
return(pccConflicts) | ||
return(pccConflicts) | ||
} | ||
if (answerOne == "Y") { | ||
answered = TRUE | ||
answered = TRUE | ||
} | ||
} | ||
} | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
pccOverconflicting = PCC.overconflicting(pccConflicts) | ||
writeLines("Are you satisfied with this configuration and do you want to\n Proceed to actual elimination of over-conflicting variant locations [P],\n Try again with different value [T],\n or Quit [Q] ? \n ") | ||
if(ask){ | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
pccOverconflicting = PCC.overconflicting(pccConflicts, ask = ask, threshold = threshold) | ||
writeLines( | ||
"Are you satisfied with this configuration and do you want to\n Proceed to actual elimination of over-conflicting variant locations [P],\n Try again with different value [T],\n or Quit [Q] ? \n " | ||
) | ||
reiterateQuestion = TRUE | ||
while (reiterateQuestion == TRUE) { | ||
answerOne = readline("(P/T/Q)") | ||
if (answerOne != "P" && answerOne != "T" && answerOne != "Q") { | ||
print("Please enter P (Proceed), T (Try again) or Q (Quit).") | ||
} | ||
if (answerOne == "T") { | ||
reiterateQuestion = FALSE | ||
} | ||
if (answerOne == "Q") { | ||
return(pccOverconflicting) | ||
} | ||
if (answerOne == "P") { | ||
reiterateQuestion = FALSE | ||
answered = TRUE | ||
} | ||
answerOne = readline("(P/T/Q)") | ||
if (answerOne != "P" && | ||
answerOne != "T" && answerOne != "Q") { | ||
print("Please enter P (Proceed), T (Try again) or Q (Quit).") | ||
} | ||
if (answerOne == "T") { | ||
reiterateQuestion = FALSE | ||
} | ||
if (answerOne == "Q") { | ||
return(pccOverconflicting) | ||
} | ||
if (answerOne == "P") { | ||
reiterateQuestion = FALSE | ||
answered = TRUE | ||
} | ||
} | ||
} | ||
} else{ | ||
pccOverconflicting = PCC.overconflicting(pccConflicts, ask = ask, threshold = threshold) | ||
} | ||
pccElimination = PCC.elimination(pccOverconflicting) | ||
pccConflicts = PCC.conflicts(pccElimination, omissionsAsReadings = omissionsAsReadings, alternateReadings = alternateReadings) | ||
pccConflicts = PCC.conflicts(pccElimination, | ||
omissionsAsReadings = omissionsAsReadings, | ||
alternateReadings = alternateReadings) | ||
if (sum(pccConflicts$conflictsTotal[, 1]) == 0) { | ||
print("There is no longer any conflict in the database. Function will stop.") | ||
return(pccConflicts) | ||
if(verbose){ | ||
cat("There is no longer any conflict in the database. Function will stop.") | ||
} | ||
return(pccConflicts) | ||
} | ||
message = paste("There is still ", nrow(pccConflicts$edgelist), "conflicts in the database. If this number is high it might indicate that : \n 1. The conflictuality index chosen was too low. \n 2. There are concurring structures in the tradition (due for instance to contamination).") | ||
writeLines(message) | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
if(ask){ | ||
cat( | ||
"There is still ", | ||
nrow(pccConflicts$edgelist), | ||
"conflicts in the database.\n", | ||
"If this number is high it might indicate that: \n", | ||
"1. The conflictuality index chosen was too low.\n", | ||
"2. There are concurring structures in the tradition (due for instance to contamination)." | ||
) | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
answerOne = readline("Do you want to proceed to contamination detection methods ? Y/N \n ") | ||
if (answerOne != "N" && answerOne != "Y") { | ||
print("Please enter Y (yes) or N (no).") | ||
print("Please enter Y (yes) or N (no).") | ||
} | ||
if (answerOne == "N") { | ||
return(pccConflicts) | ||
return(pccConflicts) | ||
} | ||
if (answerOne == "Y") { | ||
answered = TRUE | ||
answered = TRUE | ||
} | ||
} | ||
} | ||
pccContam = PCC.contam(pccConflicts, pauseAtPlot = pauseAtPlot, omissionsAsReadings = omissionsAsReadings, alternateReadings = alternateReadings) | ||
print(pccContam$conflictsDifferences) | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
pccContam = PCC.contam( | ||
pccConflicts, | ||
pauseAtPlot = pauseAtPlot, | ||
omissionsAsReadings = omissionsAsReadings, | ||
alternateReadings = alternateReadings | ||
) | ||
if(ask){ | ||
print(pccContam$conflictsDifferences) | ||
answered = FALSE | ||
while (answered == FALSE) { | ||
answerOne = readline("Do you want to define alternate configurations for stemma building ? Y/N \n ") | ||
if (answerOne != "N" && answerOne != "Y") { | ||
print("Please enter Y (yes) or N (no).") | ||
print("Please enter Y (yes) or N (no).") | ||
} | ||
if (answerOne == "N") { | ||
return(pccContam) | ||
return(pccContam) | ||
} | ||
if (answerOne == "Y") { | ||
answered = TRUE | ||
answered = TRUE | ||
pccEquipollent = PCC.equipollent(pccConflicts, ask = ask, verbose = verbose) | ||
return(pccEquipollent) | ||
} | ||
} | ||
} | ||
# and now, in the ask = FALSE mode, we will try to decide smartly for the user | ||
# Either, there are one or several wits responsible for conficts, and | ||
# we will equipollent for them, or, otherwise, we will try to do it | ||
# on a global basis | ||
myWits = rownames(pccContam$conflictsDifferences[ | ||
pccContam$conflictsDifferences + (sum(pccContam$totalByMs[,1]) / 2) | ||
== 0, , drop = FALSE | ||
]) | ||
if(is.null(myWits)){ | ||
pccEquipollent = PCC.equipollent(pccConflicts, ask = ask, scope = 'T', | ||
verbose = verbose) | ||
} else { | ||
pccEquipollent = PCC.equipollent(pccConflicts, ask = ask, scope = 'W', | ||
wits = myWits, verbose = verbose) | ||
} | ||
pccEquipollent = PCC.equipollent(pccConflicts) | ||
return(pccEquipollent) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.