# Metadata Management

## Metadata Management

Metadata provides key sample information for integrated microbiome analysis. MicrobiomeStat offers functions to update and synchronize metadata.

### Update Metadata

The `mStat_update_meta_data()` function updates metadata from a file or dataframe:

```{r
mStat_update_meta_data(
  data.obj = obj,
  map.file = "new_meta.csv" 
)
```

It can handle CSVs, TSVs, etc.

**Steps include**:

* Load metadata file or dataframe
* Replace existing `meta.dat`
* Subset feature table by intersecting samples
* Return updated data object

This allows incorporating new metadata to enable more powerful integrated analyses.

### Update Sample Names

The `mStat_update_sample_name()` function updates sample names across data components:

```{r
mStat_update_sample_name(
  data.obj = obj,
  new.name = c("s1", "s2", "s3")
)
```

It synchronizes sample names in `meta.dat`, `feature.tab`, and `feature.agg.list`.

**Key steps**:

* Check new names are valid
* Update `meta.dat` rownames
* Update `feature.agg.list` colnames
* Update `feature.tab` colnames

This maintains data consistency when updating sample identifiers.

Proper metadata management ensures high-quality integrated analyses. MicrobiomeStat empowers seamless metadata updates to enable robust microbiome discoveries.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.microbiomestat.wiki/data-manipulation-and-transformation/metadata-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
