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

Inquiry About Setting Character Weights in optim.parsimony Function #172

Open
Xinru99 opened this issue Aug 30, 2024 · 2 comments
Open

Inquiry About Setting Character Weights in optim.parsimony Function #172

Xinru99 opened this issue Aug 30, 2024 · 2 comments

Comments

@Xinru99
Copy link

Xinru99 commented Aug 30, 2024

Dear Dr. Schliep,

I hope this message finds you well.

I am currently using the phangorn package to perform a parsimony analysis on a dataset of Clematis sequences. I have encountered an issue while attempting to apply character weights using the optim.parsimony function.

Here is the code snippet I used to set the weights:

Cweight <- c(13.54, 1.81, 1.32, 4.30, 3.80, 1.07, 2.68, 1.16, 1.50, 2.64, 
             4.47, 1.96, 4.08, 9.12, 6.74, 1.31, 0.83, 1.75, 8.48, 2.36, 
             1.43, 1.73, 2.67, 1.13, 3.39, 1.09, 3.47, 0.81, 1.39, 2.65, 
             1.94, 1.09, 2.27)

parsimony_tree_weight <- optim.parsimony(nj_tree, Clematis_seq, weight = Cweight)

The analysis runs without errors, but I noticed that the results do not differ from those obtained without applying the weights. This led me to wonder if I am correctly applying the character weights, or if there is an alternative approach I should consider.

Could you please confirm whether my current use of the weight parameter in optim.parsimony is correct? If not, I would greatly appreciate any guidance or alternative methods you might suggest for incorporating character weights in parsimony analysis using phangorn.

Thank you very much for your time and for developing such a valuable tool for the community.

Best regards,
Xinru
Huazhong Agriculture Uuiversity

@KlausVigo
Copy link
Owner

Dear @Xinru99,
the optim.parsimony and pratchet functions do not have an argument weight.
See e.g. the help file ?optim.parsimony.

Can you describe what these weight should achieve. Are these weights for each column in your alignment?

The phyDat object contains an argument weight, you might try attr(Clematis_seq, "weight"). In case of an DNA alignment the weight are the counts of how often each column in the alignment is seen.

Kind regards,
Klaus

@Xinru99
Copy link
Author

Xinru99 commented Sep 6, 2024

Dear Dr. Schliep,

Thanks for your fast responding.

Actually, I have a morphological matrix, and each column is a species trait with different importance in its evolution IMO, so I want to reflect the importance during the tree reconstruction. The example data is listed below:

Here is my matrix:

A                 00011102100030001000100?200100010
B                 0000?101100110001000100?001000111
C                 00000101110111111000110?000210101
D                 00000103110120001000010?201100211
E                 0000?102000110001000??0?301210221
F                 000001011101100010001000000110121

Here are the corresponding weights for the matrix of each column above:
Cweight <- c(13.54, 1.81, 1.32, 4.30, 3.80, 1.07, 2.68, 1.16, 1.50, 2.64, 4.47, 1.96, 4.08, 9.12, 6.74, 1.31, 0.83, 1.75, 8.48, 2.36, 1.43, 1.73, 2.67, 1.13, 3.39, 1.09, 3.47, 0.81, 1.39, 2.65, 1.94, 1.09, 2.27)

I've checked the usage of phyDat, but failed to find the argument weight. Please help.

By the way, is it possible to add a constraint tree?

Looking forward to your reply!

many thanks!

Xinru

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants