dat = dat[dat.N >= n_min]
if "NSTUDY" in dat.columns and "N" in dat.columns:
dat.drop(["NSTUDY"], inplace=True, axis=1)
elif "NSTUDY" in dat.columns and "N" not in dat.columns:
nstudy_min = args.nstudy_min if args.nstudy_min else dat.NSTUDY.max()
dat = dat[dat.NSTUDY >= nstudy_min].drop(["NSTUDY"], axis=1)
After Change
if "N" in dat.columns:
n_min = args.n_min if args.n_min else dat.N.quantile(0.9) / 1.5
old = len(dat)
dat = dat[dat.N >= n_min].reset_index(drop=True)
new = len(dat)
log.log("Removed {M} SNPs with N < {MIN} ({N} SNPs remain).".format(M=old-new, N=new, MIN=n_min))