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

getDatTraits method might not be suitable for continuous traits. #86

Closed
lwtan90 opened this issue Jan 17, 2024 · 1 comment
Closed

getDatTraits method might not be suitable for continuous traits. #86

lwtan90 opened this issue Jan 17, 2024 · 1 comment

Comments

@lwtan90
Copy link

lwtan90 commented Jan 17, 2024

Hi,

If I follow the tutorial correctly, the following method will not be useful if the sample info has continuous values (such as height, weight). It will create a lot of columns for each unique number.

def getDatTraits(self, metaData):
        data = self.datExpr.obs.copy()[metaData]
        datTraits = pd.DataFrame(index=data.index)
        for i in range(data.shape[1]):
            data.iloc[:, i] = data.iloc[:, i].astype(str)
            if len(np.unique(data.iloc[:, i])) == 2:
                datTraits[data.columns[i]] = data.iloc[:, i]
                org = np.unique(data.iloc[:, i]).tolist()
                rep = list(range(len(org)))
                datTraits.replace(to_replace=org, value=rep,
                                  inplace=True)
            elif len(np.unique(data.iloc[:, i])) > 2:
                for name in np.unique(data.iloc[:, i]):
                    datTraits[name] = data.iloc[:, i]
                    org = np.unique(data.iloc[:, i])
                    rep = np.repeat(0, len(org))
                    rep[np.where(org == name)] = 1
                    org = org.tolist()
                    rep = rep.tolist()
                    datTraits.replace(to_replace=org, value=rep, inplace=True)

        return datTraits

Are there any other function to correlate the module to continuous trais?
Thank you.

Wilson

@nargesr
Copy link
Member

nargesr commented Jan 17, 2024

Hi @lwtan90

you should be able to find your answer by looking at issue #55

Please don't hesitate to reopen this issue if you still have further questions.

@nargesr nargesr closed this as completed Jan 17, 2024
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