<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calc_AF(M,major=0,minor=2):
 """calculate minor allelel frequency, by default assuming that minor==2"""

    if minor==2:
        Nhet   = (M==0).sum(axis=0)
        Nmajor = 2*(M==0).sum(axis=0)
        Nminor = 2*(M==2).sum(axis=0)
        af  = Nminor/sp.double(2*M.shape[0])
    else:
        Nmajor = (M==0).sum(axis=0)
        Nminor = (M==1).sum(axis=0)
        af  = Nminor/sp.double(1*M.shape[0])
    RV = {}
    RV['af'] = af
    RV['Nmajor'] = Nmajor
    RV['Nminor'] = Nminor
    return RV