Is logrank test and its variations affected by the inequality of classes? I am currently dealing with an home made exercise which compares the lifetime of patients who made use of a specific drug or not. For simplicity, I decided to remove censored data, but as replacement I wanted to study two scenario for which the imbalance of the two classes exists with different degrees.
What I did was computing the survival probability estimation through Kaplan Meier and therefore testing whether the two survival curves are comparable or not. I decided to use a Peto modified logrank test, but for the purpose of the question all the tests point to the same result, shown in the following plots:


So, the question is the following: by looking at the two plots, is it possible to state that logrank tests are affected by the inequality of classes? If so, what is the correct way to deal with? Should we opt for bootstrapping? The point is I cannot understand why, by looking at the pvalues returned, in the first case the two curves are considered not comparable whilst in the second, were hard inequality exists, yes.
Update: after EdM suggestion, I found that I simply got fooled by the plot. The test states that the two survival curves are different because the really difference happens on the first 10 days, which are plotted here:

All tests sustain the alternative hyphothesis, and therefore we can conclude that the two survival curves cannot be comparable given the differences in the early days of the analysis.
 A: Note your two graphics present two different survival analyses. So which one are you dealing with?
By "classes" do you mean the "Drug" versus "No drug" group? And by "inequality [of classes]" do you mean that people on drug die slightly faster than people not on drug? Or do you mean there are a lot more people in the "No drug" class?
By imbalanced groups, I assure you (as it is asked again and again and again on stack exchange) that it really makes no difference.
The log rank test is a significance test for the hazard ratio, or rate ratio, comparing the incidence of events in the two groups. For instance, focusing on 50 day survival (in the second graphic), and assuming there's no censoring: you have a 7.5% survival rate for the drug group and a 12.2% survival in the no drug group. So the hazard ratio is approximately 4.7. If there were, say 100 times as many patients in the "drug" group, we would still expect a 7.5% survival rate and a hazard ratio of 4.7. All we would get is a tighter CI and a lower p-value reflecting greater precision due to increased sample size.
No test actually depends on a balanced sample. We encounter them so often because RANDOMIZED designs invoke the added benefit of randomization: that is approximately balancing the distribution of possible confounders at baseline, and eliminating their causal influence on the random assignment of "drug". In epidemiologic/observational analyses, you must control or match on confounding factors, and a bivariate analysis is useless no matter how large (or how balanced) your sample is.
Fun fact: 1:1 randomization is not necessary, and is not even optimal (depending on the analysis). A valid design can be obtained randomizing patients in a fashion of 3:1 or 20:1 without requiring any "correction".
A: There's nothing intrinsically problematic about imbalance if both classes are large enough, but the Type I error rate of the logrank test does creep up if one class is too small in absolute numbers. Pepe and Fleming (1987) showed this when both classes were small.  I have seen the same thing with genome-wide association studies where the Type I error rates for relatively rare genetic variants were elevated even though the total sample size was large. I was surprised (not having seen the Pepe & Fleming paper at the time), because the score test in a logistic model is conservative in the same setting and I had expected the logrank test to behave the same way.
