This is a test version of Biostars. For the public version, visit https://www.biostars.org.
"NaN " values are copied instead of float values (pd dataframe to adata.obs)

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

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

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

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

Fixed it

Index are different and aligned the index!! It Works

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

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.

0 answers

No answers yet.

Log in to answer this question.