"NaN " values are copied instead of float values (pd dataframe to adata.obs)
0
0
Entering edit mode
2.5 years ago
akilabioinfo ▴ 10

Hello all,

I have used dropletutils to identify the empty droplet. Now i would like to add FDR information in the adata.obs.

But all the values are "NaN" when i try to copy the FDR values to adata.obs

enter code here
  adata=anndata.read_h5ad("/home/akila/data/adata.h5ad")
#metadata includes the FDR information from droplet utils e_out
  metadata=pd.read_csv("/home/akila/data/metadata.csv")
  adata.obs["FDR"]=metadata["FDR"]

`I have also tried to replace "NaN" values with "1" and proceed the same but still these float values are replaced with Nan while copying into adata.obs

How to fix this.Help me

enter image description here

I have attached the sample output

pandas anndata • 1.4k views
ADD COMMENT
1
Entering edit mode

please post some example data from both the data frames. check the dtype of the dataframe esp FDR column in each of the data frame.

ADD REPLY
0
Entering edit mode

"Join" the data using a matching column instead of doing this blind assignment operation.

ADD REPLY
0
Entering edit mode

I have done that too!! its not working. I couldnt able to copy from my metadata to anndata adata.obs(returns NAN values)

ADD REPLY
0
Entering edit mode

Follow cpad0112's advice. In the meantime, please do not paste screenshots of plain text content, it is counterproductive. You can copy paste the content directly here (using the code formatting option shown below), or use a GitHub Gist if the content volume exceeds allowed length here.

code_formatting

ADD REPLY
0
Entering edit mode

Fixed it

Index are different and aligned the index!! It Works

adata.obs['FDR'] = metadata['FDR'].to_numpy()
ADD REPLY

Login before adding your answer.

Traffic: 1809 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6