adegenet icon indicating copy to clipboard operation
adegenet copied to clipboard

Testing H0: Hexp= Hobs

Open GrimPerez opened this issue 4 years ago • 5 comments

Good day, I appreciate your time and patience in my issue. I am writing to ask about how to carry out a statistic test to test if there is any significant difference between subpopulation1 Hexp and subpopulation 1Hobs. (H0: Hexp = Hobs)

Example: I am using genind and SNPs. I separate my population into subpopulations. I then calculate for the mean Hexp and mean Hobs and acquire them for each subpopulation.

I tried using bartletttest mean.hexp (mean of Hexp for each subpopulation. eg. S1,S2,S3...) mean.hobs (mean of Hobs for each subpopulation. eg. S1,S2,S3...)

bartlett.test(list(mean.hexp$S1, mean.hobs$S1))

I get the following error: "Error in mean.hexp$S1 : $ operator is invalid for atomic vectors"

Thank you for your time and patience, Grimar A. Perez

GrimPerez avatar Sep 20 '19 06:09 GrimPerez

You will probably need to use square brackets like so: mean.hexp[[“S1”]]

Sent from my iPhone

On Sep 20, 2019, at 07:36, GrimPerez [email protected] wrote:

Good day, I appreciate your time and patience in my issue. I am writing to ask about how to carry out a statistic test to test if there is any significant difference between subpopulation1 Hexp and subpopulation 1Hobs. (H0: Hexp = Hobs)

Example: I am using genind and SNPs. I separate my population into subpopulations. I then calculate for the mean Hexp and mean Hobs and acquire them for each subpopulation.

I tried using bartletttest mean.hexp (mean of Hexp for each subpopulation. eg. S1,S2,S3...) mean.hobs (mean of Hobs for each subpopulation. eg. S1,S2,S3...)

bartlett.test(list(mean.hexp$S1, mean.hobs$S1))

I get the following error: "Error in mean.hexp$S1 : $ operator is invalid for atomic vectors"

Thank you for your time and patience, Grimar A. Perez

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

zkamvar avatar Sep 20 '19 06:09 zkamvar

I still get an error.

I will try to expand on what I am using. I must apologize by saying that I am not an expert. gi= genind object.

n.pop <- seppop(gi) mean.hobs <- do.call("c", lapply(n.pop, function(x) mean(summary(x)$Hobs))) mean.hobs[is.nan(mean.hobs)] <- NA

n.pop <- seppop(gi) mean.hexp <- do.call("c", lapply(n.pop, function(x) mean(summary(x)$Hexp))) mean.hexp[is.nan(mean.hexp)] <- NA

bartlett.test (list(mean.hexp[["S1"]], mean.hobs[["S1"]])) *Error: There must be at least 2 observations in each group

bartlett.test (mean.hexp[["S1"]], mean.hobs[["S1"]]) *Error: all observations are in the same group

bartlett.test (mean.hexp$S1, mean.hobs$S1) *Error: $ operator is invalid for atomic vectors.

Your help will be sincerely appreciated. Thank you for your time.

Sincerely, Grimar A. Perez

GrimPerez avatar Sep 21 '19 00:09 GrimPerez

Good day,

I was hoping to get some insight and clarification with the following. Why does Hobs return NA instead of a value for one of my populations?

Screen Shot 2019-10-08 at 10 12 44

GrimPerez avatar Oct 08 '19 03:10 GrimPerez

Hello, it's difficult to know for this situation. It could be that you forgot to add na.rm in a summary calculation.

zkamvar avatar Oct 08 '19 08:10 zkamvar

Thank you very much. The na.rm fixed the NA issue. I tried running bartlett.test after resolving the NA issue, but I still get the same error. My data is a genind object. Is there any recommended script that you might suggest? your help is sincerely appreciated.

Is it possible to run Chi-square Test on my genind object to test H0: Hexp= Hobs?

Regards, Grimar A. Perez

GrimPerez avatar Nov 05 '19 13:11 GrimPerez